| name | litestar-exceptions |
| description | Auto-activate for exception_handlers, HTTPException, ApplicationError, NotFoundError, ValidationException, PermissionDeniedException, RFC 9457, or domain error mapping. Not for client-side errors. |
Litestar Exceptions
Use this skill for domain exception hierarchies, handler registration, and HTTP error response shape.
Code Style Rules
- Centralize domain-to-HTTP translation in exception handlers.
- Keep route handlers free of repetitive try/except blocks.
- Use domain exception classes when services need stable error contracts.
- Keep validation errors aligned with DTO and OpenAPI behavior.
- Use
ProblemDetailsPlugin explicitly when the API contract requires RFC
9457. Native HTTPException responses are Litestar's JSON error envelope.
Quick Reference
Workflow
- Define a small domain exception hierarchy.
- Register handlers at app config.
- Raise domain exceptions from services or Litestar exceptions from framework boundaries.
- Test response status and payload shape.
Guardrails
- Do not catch exceptions in every handler.
- Do not leak database exception messages to API clients.
- Do not return inconsistent error payloads from neighboring routes.
- Do not replace Litestar validation behavior without a clear API reason.
- Do not describe native
HTTPException responses as Problem Details unless
ProblemDetailsPlugin is configured for them.
Validation Checkpoint
Example
class ApplicationError(HTTPException):
status_code = 500
class ConflictError(ApplicationError):
status_code = 409
References Index
Official References
Shared Styleguide Baseline