Skip to content

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

Bases: HTTPException

Request conflict with the current state of the target resource.

ForbiddenException

Bases: HTTPException

Server understands the request but refuses to authorize it.

after_exception_hook_handler

after_exception_hook_handler(exc, scope, state)

Logs exception and returns appropriate response.

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

repository_exception_to_http_response(request, exc)

Transform repository exceptions to HTTP exceptions.

Parameters:

Name Type Description Default
request Request

The request that experienced the exception.

required
exc RepositoryException

Exception raised during handling of the request.

required

Returns:

Type Description
Response

Exception response appropriate to the type of original exception.

service_exception_to_http_response

service_exception_to_http_response(request, exc)

Transform service exceptions to HTTP exceptions.

Parameters:

Name Type Description Default
request Request

The request that experienced the exception.

required
exc ServiceException

Exception raised during handling of the request.

required

Returns:

Type Description
Response

Exception response appropriate to the type of original exception.