Skip to content

exceptions

Gathers all exceptions thrown by ormar.

AsyncOrmException

Bases: Exception

Base ormar Exception

Source code in ormar\exceptions.py
 6
 7
 8
 9
10
11
class AsyncOrmException(Exception):
    """
    Base ormar Exception
    """

    pass

ModelDefinitionError

Bases: AsyncOrmException

Raised for errors related to the model definition itself:

  • setting @property_field on method with arguments other than func(self)
  • defining a Field without required parameters
  • defining a model with more than one primary_key
  • defining a model without primary_key
  • setting primary_key column as pydantic_only
Source code in ormar\exceptions.py
14
15
16
17
18
19
20
21
22
23
24
25
class ModelDefinitionError(AsyncOrmException):
    """
    Raised for errors related to the model definition itself:

    * setting @property_field on method with arguments other than func(self)
    * defining a Field without required parameters
    * defining a model with more than one primary_key
    * defining a model without primary_key
    * setting primary_key column as pydantic_only
    """

    pass

ModelError

Bases: AsyncOrmException

Raised for initialization of model with non-existing field keyword.

Source code in ormar\exceptions.py
28
29
30
31
32
33
class ModelError(AsyncOrmException):
    """
    Raised for initialization of model with non-existing field keyword.
    """

    pass

ModelListEmptyError

Bases: AsyncOrmException

Raised for objects is empty when bulk_update

Source code in ormar\exceptions.py
86
87
88
89
90
91
class ModelListEmptyError(AsyncOrmException):
    """
    Raised for objects is empty when bulk_update
    """

    pass

ModelPersistenceError

Bases: AsyncOrmException

Raised for update of models without primary_key set (cannot retrieve from db) or for saving a model with relation to unsaved model (cannot extract fk value).

Source code in ormar\exceptions.py
69
70
71
72
73
74
75
class ModelPersistenceError(AsyncOrmException):
    """
    Raised for update of models without primary_key set (cannot retrieve from db)
    or for saving a model with relation to unsaved model (cannot extract fk value).
    """

    pass

MultipleMatches

Bases: AsyncOrmException

Raised for database queries that should return one row (i.e. get, first etc.) but has multiple matching results in response.

Source code in ormar\exceptions.py
44
45
46
47
48
49
50
class MultipleMatches(AsyncOrmException):
    """
    Raised for database queries that should return one row (i.e. get, first etc.)
    but has multiple matching results in response.
    """

    pass

NoMatch

Bases: AsyncOrmException

Raised for database queries that has no matching result (empty result).

Source code in ormar\exceptions.py
36
37
38
39
40
41
class NoMatch(AsyncOrmException):
    """
    Raised for database queries that has no matching result (empty result).
    """

    pass

QueryDefinitionError

Bases: AsyncOrmException

Raised for errors in query definition:

  • using contains or icontains filter with instance of the Model
  • using Queryset.update() without filter and setting each flag to True
  • using Queryset.delete() without filter and setting each flag to True
Source code in ormar\exceptions.py
53
54
55
56
57
58
59
60
61
62
class QueryDefinitionError(AsyncOrmException):
    """
    Raised for errors in query definition:

    * using contains or icontains filter with instance of the Model
    * using Queryset.update() without filter and setting each flag to True
    * using Queryset.delete() without filter and setting each flag to True
    """

    pass

SignalDefinitionError

Bases: AsyncOrmException

Raised when non callable receiver is passed as signal callback.

Source code in ormar\exceptions.py
78
79
80
81
82
83
class SignalDefinitionError(AsyncOrmException):
    """
    Raised when non callable receiver is passed as signal callback.
    """

    pass