exceptions#

Application exceptions

Litestar-saqlalchemy exception types.

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

exception app.lib.exceptions.AuthorizationError(*args: Any, detail: str = '')[source]#

Bases: ApplicationClientError

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

Initialize AdvancedAlchemyException.

Parameters:
  • *args – args are converted to str before passing to Exception

  • detail – detail of the exception.

exception app.lib.exceptions.HealthCheckConfigurationError(*args: Any, detail: str = '')[source]#

Bases: ApplicationError

An error occurred while registering an health check.

Initialize AdvancedAlchemyException.

Parameters:
  • *args – args are converted to str before passing to Exception

  • detail – detail of the exception.

exception app.lib.exceptions.ApplicationError(*args: Any, detail: str = '')[source]#

Bases: Exception

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

Initialize AdvancedAlchemyException.

Parameters:
  • *args – args are converted to str before passing to Exception

  • detail – detail of the exception.

__init__(*args: Any, detail: str = '') None[source]#

Initialize AdvancedAlchemyException.

Parameters:
  • *args – args are converted to str before passing to Exception

  • detail – detail of the exception.

async app.lib.exceptions.after_exception_hook_handler(exc: Exception, _scope: Scope) None[source]#

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:
  • exc – the exception that was raised.

  • _scope – scope of the request