Error Classes¶
These error classes should be used in your Logic Functions to abstract out the HTTP layer. Doctor provides custom exceptions which will be converted to the correct HTTP Exception by the library. This allows logic functions to be easily reused by other logic in your code base without it having knowledge of the HTTP layer.
-
exception
doctor.errors.
DoctorError
(message, errors=None)[source]¶ Bases:
ValueError
Base error class for Doctor.
-
exception
doctor.errors.
ForbiddenError
(message, errors=None)[source]¶ Bases:
doctor.errors.DoctorError
Raised when a request is forbidden for the authorized user.
Corresponds to a HTTP 403 Forbidden error.
-
exception
doctor.errors.
ImmutableError
(message, errors=None)[source]¶ Bases:
doctor.errors.DoctorError
Raised for immutable errors for a schema.
Corresponds to a HTTP 409 Conflict error.
-
exception
doctor.errors.
InternalError
(message, errors=None)[source]¶ Bases:
doctor.errors.DoctorError
Raised when there is an internal server error.
Corresponds to a HTTP 500 Internal Server Error.
-
exception
doctor.errors.
InvalidValueError
(message, errors=None)[source]¶ Bases:
doctor.errors.DoctorError
Raised for errors when doing more complex validation that can’t be done in a schema.
Corresponds to a HTTP 400 Bad Request error.
-
exception
doctor.errors.
NotFoundError
(message, errors=None)[source]¶ Bases:
doctor.errors.DoctorError
Raised when a resource is not found.
Corresponds to a HTTP 404 Not Found error.
-
exception
doctor.errors.
ParseError
(message, errors=None)[source]¶ Bases:
doctor.errors.DoctorError
Raised when a value cannot be parsed into an appropriate type.
-
exception
doctor.errors.
SchemaError
(message, errors=None)[source]¶ Bases:
doctor.errors.DoctorError
Raised for errors in a schema.
-
exception
doctor.errors.
SchemaLoadingError
(message, errors=None)[source]¶ Bases:
doctor.errors.DoctorError
Raised when loading a resource and it is invalid.
-
exception
doctor.errors.
SchemaValidationError
(message, errors=None)[source]¶ Bases:
doctor.errors.DoctorError
Raised for errors when validating things against a schema.
-
doctor.errors.
SchematicError
¶ Alias for DoctorError, for backwards compatibility.
alias of
doctor.errors.DoctorError
-
exception
doctor.errors.
TypeSystemError
(detail=None, cls=None, code=None, errors=None)[source]¶ Bases:
doctor.errors.DoctorError
An error that represents an invalid value for a type.
This is borrowed from apistar: https://github.com/encode/apistar/blob/ 50dd15f0878f0a7c50ce829a72adb276782bcb78/apistar/exceptions.py#L4-L15
Parameters: - detail (
Union
[str
,dict
,None
]) – Detail about the error. - cls (
Optional
[type
]) – The class type that was being instantiated. - code (
Optional
[str
]) – The error code. - errors (
Optional
[dict
]) – A dict containing all validation errors during the request. The key is the param name and the value is the error message.
- detail (
Bases:
doctor.errors.DoctorError
Raised when a request is unauthorized.
Corresponds to a HTTP 401 Unauthorized error.