Exceptions

Exception classes shared across the framework. The ApiError hierarchy is the error contract of LambdaApi: handlers raise these, and they render as JSON error envelopes with the matching HTTP status code.

exception sosw.components.exceptions.EventNotFromSourceException[source]
exception sosw.components.exceptions.ApiError(message: str = None, status_code: int = None, error_code: str = None)[source]

Base class for exceptions that map to an HTTP response of sosw.lambda_api.LambdaApi.

Handlers raise these (or subclasses); LambdaApi renders them as a JSON error envelope: {'error': {'code': error_code, 'message': message}} with the appropriate HTTP status code.

Subclasses override the class attributes; per-instance overrides are supported through the constructor keyword arguments.

Parameters:
  • message (str) – Human readable error description. Defaults to default_message.

  • status_code (int) – Optional per-instance override of the HTTP status code.

  • error_code (str) – Optional per-instance override of the machine-readable error code.

exception sosw.components.exceptions.BadRequestError(message: str = None, status_code: int = None, error_code: str = None)[source]

The request is malformed or fails validation. Maps to HTTP 400.

exception sosw.components.exceptions.UnauthorizedError(message: str = None, status_code: int = None, error_code: str = None)[source]

The caller identity cannot be established (missing/expired credentials). Maps to HTTP 401.

exception sosw.components.exceptions.ForbiddenError(message: str = None, status_code: int = None, error_code: str = None)[source]

The caller is authenticated, but not allowed to perform the action. Maps to HTTP 403.

exception sosw.components.exceptions.NotFoundError(message: str = None, status_code: int = None, error_code: str = None)[source]

The requested resource or route does not exist. Maps to HTTP 404.

exception sosw.components.exceptions.ConflictError(message: str = None, status_code: int = None, error_code: str = None)[source]

The request conflicts with the current state of the resource. Maps to HTTP 409.

exception sosw.components.exceptions.ServerError(message: str = None, status_code: int = None, error_code: str = None)[source]

Unexpected server-side failure. Maps to HTTP 500.