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.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);
LambdaApirenders 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.