Exceptions¶
These exception classes are used in client implementations.
Base¶
ApplicationError
¶
Authorization¶
AuthorizationError
¶
Permissions¶
PermissionDeniedError
¶
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.
BadRequestError
¶
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.
reason = reason
¶
Bad request reason message
Entity¶
EntityNotFoundError
¶
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
EntityAlreadyExistsError
¶
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
Service¶
ServiceError
¶
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