plugins/litestar/skills/litestar-exception-handling/SKILL.md
Implement Litestar exception handling with HTTPException, built-in exception subclasses, custom exception handlers, layered overrides, status-code mappings, and stable API error contracts. Use when translating domain failures, validation errors, middleware/dependency failures, or router-generated HTTP errors into deterministic Litestar responses. Do not use for authentication or authorization policy design that belongs in security layers.
npx skillsauth add alti3/litestar-skills litestar-exception-handlingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
HTTPException or by mapping another exception type through an exception handler.404 Not Found and 405 Method Not Allowed when those responses must be customized.HTTPException or its subclasses when the handler should raise an HTTP-aware error directly.litestar-openapi route metadata and security docs.404 and 405, which must be handled at app scope.HTTPException subclasses directly for clear HTTP semantics such as 401, 403, 404, 429, or 503.exception_handlers when business logic should stay transport-agnostic.500 handling and lower-level overrides only where behavior genuinely differs.Read only the sections you need:
HTTPException constructor behavior, validation warnings, headers, extra, and websocket-related exceptions, read references/built-in-exceptions.md.404/405 rule, read references/handler-patterns.md.ValidationException.extra as potentially user-visible diagnostic data.500 responses generic for clients and detailed in logs.400 response.404 or 405 below the app layer.404 and 405 customization is registered on the Litestar app instance.500 responses and remain observable in logs.litestar-authentication or litestar-security for auth-specific 401 and 403 strategy.litestar-responses when the main task is response formatting rather than exception mapping.litestar-testing for exhaustive failure-path assertions and override coverage.litestar-openapi when documented error responses or security-related failure docs need to match runtime behavior.litestar-logging when exception observability, redaction, or structured logging is part of the task.development
Build Litestar WebSocket endpoints with low-level websocket handlers, websocket listeners, websocket streams, dependency injection, custom websocket classes, transport-mode control, and graceful connection lifecycle handling. Use when implementing bidirectional real-time communication, reactive websocket message handling, or proactive server push over WebSockets. Do not use for server-side pub/sub fanout that is better expressed with channels alone.
tools
Test Litestar applications with TestClient, AsyncTestClient, create_test_client, websocket test helpers, dependency overrides, mocked dependencies, lifecycle-aware fixtures, and deterministic success and failure assertions. Use when adding or fixing Litestar test coverage, including exception contracts, override precedence, websocket behavior, event-bus side effects, or live-server-only response patterns. Do not use as a substitute for production observability or runtime debugging strategy.
development
Configure Litestar templating with `TemplateConfig`, Jinja/Mako/MiniJinja engines, file-or-string `Template` responses, request and CSRF-aware context, template callables, and custom engine integration. Use when implementing or fixing server-rendered HTML in Litestar. Do not use for static asset serving or pure JSON API endpoints.
development
Configure Litestar stores and the store registry for caching, server-side sessions, rate limiting, and other key-value state with explicit backend selection, bytes-safe data handling, TTL and renewal policy, namespacing, registry wiring, and lifecycle cleanup. Use when a Litestar app depends on `MemoryStore`, `FileStore`, `RedisStore`, `ValkeyStore`, or `StoreRegistry`. Do not use for relational persistence, domain repositories, or response-caching policy details that belong in database or caching-focused skills.