Exception Catalog
Every typed exception class exported by the framework.
Base classes
LaurenError
class LaurenError(message: str = '', detail: dict[str, Any] | None = None, headers: Mapping[str, str] | Iterable[tuple[str, str]] | None = None)Base class for all lauren framework errors.
LaurenError.to_payload
def to_payload(self) -> dict[str, Any]Return the canonical JSON payload for this error.
StartupError
class StartupErrorBase class for configuration errors raised by LaurenFactory.create (never HTTP-mapped).
HTTPError
class HTTPError(message: str = '', detail: dict[str, Any] | None = None, headers: Mapping[str, str] | Iterable[tuple[str, str]] | None = None, status_code: int | None = None, code: str | None = None)Base class for errors mapped to HTTP responses.
Subclass it (or one of the built-in leaves such as NotFoundError)
to mint a stable domain code. status_code= and code= passed to
the constructor override the class attributes on that one instance — an
escape hatch for one-offs and for library code that maps foreign errors.
problem_type / problem_title set the RFC 9457 type and
title members when the app uses a problem-details error_format.
LifecycleError
class LifecycleErrorBase class for errors around startup, shutdown and lifecycle hooks.
Startup errors
RouterConflictError
class RouterConflictErrorTwo routes share the same (method, path) signature.
CircularDependencyError
class CircularDependencyErrorA cycle was detected in the DI graph.
CircularModuleError
class CircularModuleErrorA cycle was detected in the module import graph.
DecoratorUsageError
class DecoratorUsageErrorA decorator or provider helper was used incorrectly — most often without parentheses.
@controller, @injectable, @module, and the HTTP verb
decorators (@get, @post, ...) must be invoked with arguments
(or empty parentheses) so their configuration is always explicit:
@controller("/pets") # correct
@controller() # correct — defaults are fine
@controller # rejected — ambiguousMissingProviderError
class MissingProviderErrorNo provider is registered for a requested token.
ProtocolAmbiguityError
class ProtocolAmbiguityErrorA protocol has multiple providers but multi=False was requested.
ModuleExportViolation
class ModuleExportViolationA module exports a provider it neither declares nor imports.
LifecycleConfigError
class LifecycleConfigErrorA lifecycle-bound declaration is misused (a hook on a non-method, a hosted service or job on a non-singleton, …).
MetadataInheritanceError
class MetadataInheritanceErrorInjectable metadata was inherited from a base class (forbidden).
DuplicateBindingError
class DuplicateBindingErrorThe same class or token is registered twice in one container.
UnresolvableParameterError
class UnresolvableParameterErrorA handler or provider parameter cannot be resolved to an extractor or dep.
DIScopeViolationError
class DIScopeViolationErrorA singleton depends on a request-scoped provider (or similar).
MiddlewareConfigError
class MiddlewareConfigErrorA middleware lacks dispatch(request, call_next), or @use_middlewares cannot run where placed.
GuardConfigError
class GuardConfigErrorA guard lacks can_activate(context), or @use_guards cannot run where placed.
InterceptorConfigError
class InterceptorConfigErrorAn interceptor lacks intercept(ctx, call_handler), or @use_interceptors cannot run where placed.
ExceptionHandlerConfigError
class ExceptionHandlerConfigErrorAn @exception_handler / @use_exception_handlers was misused.
Raised when:
@exception_handleris invoked with no exception types or with something that is not aBaseExceptionsubclass;@exception_handlerdecorates a class without acatchmethod;@use_exception_handlersreferences a class / function that was never decorated with@exception_handler.
SessionConfigError
class SessionConfigErrorA SessionConfig was invalid, or a Session was
injected into a handler in an app that did not enable sessions.
Raised at startup (inside LaurenFactory.create) when:
same_site="none"is combined withsecure=False(browsers reject such cookies);- a
__Host-/__Secure-cookie-name prefix is used without the matchingsecure/path/domainconstraints; - the chosen store requires a signing secret but none was supplied;
max_age/idle_timeoutis non-positive;- a handler declares a
session: Sessionparameter butsessions=SessionConfig(...)was never passed to the factory.
Joins the existing *ConfigError family (MiddlewareConfigError,
GuardConfigError, InterceptorConfigError,
ExceptionHandlerConfigError).
OpenAPISchemaError
class OpenAPISchemaErrorReserved for strict OpenAPI generation — not raised yet.
A schema that cannot be generated currently degrades to a generic
{"type": "object"} entry instead of failing startup.
HTTP errors
ExtractorError
class ExtractorErrorA request value could not be extracted or validated.
ExtractorError.from_issues
def from_issues(cls, issues: Iterable[Any], field: str | None = None, message: str | None = None, include_input: bool = False, detail: Mapping[str, Any] | None = None) -> SelfBuild a 422 from validation issues (ValidationIssue objects or {loc, type, msg} dicts).
detail["issues"] holds the issues as {"loc", "type", "msg", "ctx"?}
dicts ("input" only with include_input). The 1.x keys stay
alongside: detail["field"] names the first failing parameter and
detail["errors"] lists "loc: msg" strings. The message is the
single issue's text, or "N validation errors".
ExtractorFieldError
class ExtractorFieldErrorOne parameter is missing or violates a field constraint.
BadRequestError
class BadRequestErrorThe request is malformed in a way that is not schema validation.
RFC 9110 §15.5.1. Use it for unparsable input (broken JSON or UTF-8, a
tampered cursor); field-level validation failures are 422
ExtractorError responses.
UnauthorizedError
class UnauthorizedError(message: str = '', challenge: str | Iterable[str] | None = None, detail: dict[str, Any] | None = None, headers: Mapping[str, str] | Iterable[tuple[str, str]] | None = None, status_code: int | None = None, code: str | None = None)Authentication is missing or invalid; challenge= sets WWW-Authenticate.
RFC 9110 §15.5.2: a 401 must carry at least one challenge. Pass one
string ('Bearer realm="api"') or several (each becomes its own
WWW-Authenticate header).
ForbiddenError
class ForbiddenErrorThe caller is not allowed — also what a guard returning False raises by default.
A guard class can declare deny_error = UnauthorizedError (or another
HTTPError subclass) to answer its denials with that error
instead.
NotFoundError
class NotFoundErrorThe requested resource does not exist — the domain 404.
RFC 9110 §15.5.5. Subclass it for domain codes
(class UserNotFound(NotFoundError): code = "user_not_found"). Routing
misses raise its subclass RouteNotFoundError.
RouteNotFoundError
class RouteNotFoundErrorNo route matches the request path.
MethodNotAllowedError
class MethodNotAllowedError(message: str = '', allow: Iterable[str] | None = None, detail: dict[str, Any] | None = None, headers: Mapping[str, str] | Iterable[tuple[str, str]] | None = None, status_code: int | None = None, code: str | None = None)The path matches, but not for this HTTP method; allow= sets the Allow header.
RFC 9110 §15.5.6 requires Allow on every 405. The header is emitted
wherever the error is raised — by the router or by a handler.
NotAcceptableError
class NotAcceptableErrorNo available representation matches the request's Accept headers.
RFC 9110 §15.5.7. Raised by content negotiation that is configured to be strict.
ConflictError
class ConflictErrorThe request conflicts with the current state of the resource.
RFC 9110 §15.5.10 — uniqueness violations, state-machine conflicts, idempotency keys replayed with a different body.
GoneError
class GoneErrorThe resource existed but has been removed permanently.
RFC 9110 §15.5.11 — deleted resources, API versions past their sunset date.
PreconditionFailedError
class PreconditionFailedErrorA conditional request header (If-Match, If-Unmodified-Since) evaluated to false.
RFC 9110 §15.5.13 — the optimistic-concurrency answer to a stale update.
RequestBodyTooLarge
class RequestBodyTooLargeThe request body exceeds max_body_size.
UnsupportedMediaTypeError
class UnsupportedMediaTypeErrorThe request body's Content-Type is not one the route accepts.
Raised before the body is read when
ContentConfig(strict_content_type=True) is in effect and a JSON body
parameter receives a non-JSON (or missing) Content-Type.
TooManyRequestsError
class TooManyRequestsError(message: str = '', retry_after: int | float | timedelta | datetime | None = None, detail: dict[str, Any] | None = None, headers: Mapping[str, str] | Iterable[tuple[str, str]] | None = None, status_code: int | None = None, code: str | None = None)The client sent too many requests; retry_after= sets Retry-After.
RFC 6585 §4. retry_after takes seconds (int / float), a
timedelta or a timezone-aware datetime (rendered as an HTTP-date).
ServiceUnavailableError
class ServiceUnavailableError(message: str = '', retry_after: int | float | timedelta | datetime | None = None, detail: dict[str, Any] | None = None, headers: Mapping[str, str] | Iterable[tuple[str, str]] | None = None, status_code: int | None = None, code: str | None = None)The server cannot handle the request right now; retry_after= sets Retry-After.
RFC 9110 §15.6.4 — draining, maintenance windows, load shedding, a failing readiness check.
RequestTimeoutError
class RequestTimeoutError(message: str = '', retry_after: int | float | timedelta | datetime | None = None, detail: dict[str, Any] | None = None, headers: Mapping[str, str] | Iterable[tuple[str, str]] | None = None, status_code: int | None = None, code: str | None = None)A server-side deadline was exceeded while handling the request (504).
Not HTTP 408 — 408 means the client was too slow to send its request,
which the ASGI server handles. This error means the handler (or an
upstream call it made) blew its deadline; the request_timeout code
matches the envelope lauren-middlewares' timeout middleware emits.
retry_after= optionally sets Retry-After.
MissingStateError
class MissingStateErrorrequest.state.require(key, T) found no value for key.
StateTypeError
class StateTypeErrorA request.state value has the wrong type for get_typed / require.
Lifecycle errors
LifecycleViolationError
class LifecycleViolationErrorA lifecycle operation was used in the wrong state (startup() twice, a mutator after compile).
DestructError
class DestructErrorA @pre_destruct hook raised during shutdown (collected; shutdown continues).
DestructTimeoutError
class DestructTimeoutErrorA @pre_destruct hook exceeded its timeout (collected; shutdown continues).
DrainTimeoutError
class DrainTimeoutErrorReserved: not raised — a drain timeout at shutdown is logged as a warning.