Исключения
Эти классы исключений используются в реализациях клиента.
Базовые
Bases: ABC, Exception
Base class for all exceptions raised by Horizon.
Source code in horizon/commons/exceptions/base.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
message
abstractmethod
property
Message string
details
abstractmethod
property
Details related to specific error
Авторизация
Bases: ABC, Exception
Base class for all exceptions raised by Horizon.
Source code in horizon/commons/exceptions/base.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
message
abstractmethod
property
Message string
details
abstractmethod
property
Details related to specific error
Разрешения
Bases: ApplicationError
Permission denied for performing the requested action.
Examples
from horizon.commons.exceptions import PermissionDeniedError raise PermissionDeniedError(required_role="DEVELOPER", actual_role="GUEST") Traceback (most recent call last): horizon.commons.exceptions.PermissionDeniedError: Permission denied. User has role GUEST but action requires at least DEVELOPER.
Source code in horizon/commons/exceptions/permission.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
message
property
details
property
required_role = required_role
instance-attribute
Required role to perform action
actual_role = actual_role
instance-attribute
Actual user role
Bases: ApplicationError
Bad request error.
This exception should be raised when a request cannot be processed due to client-side errors (e.g., invalid data, duplicate entries).
Examples
from horizon.commons.exceptions import BadRequestError raise BadRequestError("Duplicate username detected. Each username must appear only once.") Traceback (most recent call last): horizon.commons.exceptions.BadRequestError: Duplicate username detected. Each username must appear only once.
Source code in horizon/commons/exceptions/bad_request.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
reason = reason
instance-attribute
Bad request reason message
Сущность
Bases: ApplicationError
Entity not found.
Examples
from horizon.commons.exceptions import EntityNotFoundError raise EntityNotFoundError("User", "username", "test") Traceback (most recent call last): horizon.commons.exceptions.entity.EntityNotFoundError: User with username='test' not found
Source code in horizon/commons/exceptions/entity.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
message
property
details
property
entity_type = entity_type
instance-attribute
Entity type
field = field
instance-attribute
Entity identifier field
value = value
instance-attribute
Entity identifier value
Bases: ApplicationError
Entity with same identifier already exists.
Examples
from horizon.commons.exceptions import EntityNotFoundError raise EntityAlreadyExistsError("User", "username", "test") Traceback (most recent call last): horizon.commons.exceptions.entity.EntityAlreadyExistsError: User with username='test' already exists
Source code in horizon/commons/exceptions/entity.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
message
property
details
property
entity_type = entity_type
instance-attribute
Entity type
field = field
instance-attribute
Entity identifier field
value = value
instance-attribute
Entity identifier value
Сервис
Bases: ApplicationError
Service used by application have not responded properly.
Examples
from horizon.commons.exceptions import ServiceError raise ServiceError("Some server response is invalid") Traceback (most recent call last): horizon.commons.exceptions.service.ServiceError: Some server response is invalid
Source code in horizon/commons/exceptions/service.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |