Skip to content

exceptions

Starlite-saqlalchemy exception types.

Also, defines functions that translate service and repository exceptions into HTTP exceptions.

AuthorizationError

Bases: StarliteSaqlalchemyClientError

A user tried to do something they shouldn't have.

ConflictError

Bases: StarliteSaqlalchemyClientError

Exception for data integrity errors.

HealthCheckConfigurationError

Bases: StarliteSaqlalchemyError

An error occurred while registering an health check.

NotFoundError

Bases: StarliteSaqlalchemyClientError

Referenced identity doesn't exist.

StarliteSaqlalchemyClientError

Bases: StarliteSaqlalchemyError

Base exception type for client errors.

StarliteSaqlalchemyError

Bases: Exception

Base exception type for the lib's custom exception types.

after_exception_hook_handler async

after_exception_hook_handler(exc, _scope, _state)

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

starlite_saqlalchemy_exception_to_http_response

starlite_saqlalchemy_exception_to_http_response(request, exc)

Transform repository exceptions to HTTP exceptions.

Parameters:

Name Type Description Default
request Request[Any, Any]

The request that experienced the exception.

required
exc StarliteSaqlalchemyError

Exception raised during handling of the request.

required

Returns:

Type Description
Response[ExceptionResponseContent]

Exception response appropriate to the type of original exception.