exceptions
Definition of extra HTTP exceptions that aren't included in Starlite.
Also, defines functions that translate service and repository exceptions into HTTP exceptions.
ConflictException ¶
ForbiddenException ¶
after_exception_hook_handler
async
¶
Binds exc_info key with exception instance as value to structlog
context vars.
This must be a coroutine so that it is not wrapped in a thread where we'll lose context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exc |
Exception
|
the exception that was raised. |
required |
_scope |
Scope
|
scope of the request |
required |
_state |
State
|
application state |
required |
repository_exception_to_http_response ¶
Transform repository exceptions to HTTP exceptions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request |
Request[Any, Any]
|
The request that experienced the exception. |
required |
exc |
RepositoryException
|
Exception raised during handling of the request. |
required |
Returns:
| Type | Description |
|---|---|
Response[ExceptionResponseContent]
|
Exception response appropriate to the type of original exception. |
service_exception_to_http_response ¶
Transform service exceptions to HTTP exceptions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request |
Request[Any, Any]
|
The request that experienced the exception. |
required |
exc |
ServiceException
|
Exception raised during handling of the request. |
required |
Returns:
| Type | Description |
|---|---|
Response[ExceptionResponseContent]
|
Exception response appropriate to the type of original exception. |