skills-catalog/ln-772-error-handler-setup/SKILL.md
Configures global exception handling middleware. Use when adding centralized error handling to .NET or Python backends.
npx skillsauth add levnikolaevich/claude-code-skills ln-772-error-handler-setupInstall 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.
Type: L3 Worker Category: 7XX Project Bootstrap
Configures global error handling for .NET and Python backend applications.
| Aspect | Details | |--------|---------| | Input | Context Store from ln-770 | | Output | Exception handling middleware and custom exceptions | | Stacks | .NET (ASP.NET Core Middleware), Python (FastAPI exception handlers) |
Accept Context Store from coordinator.
Required Context:
STACK: .NET or PythonFRAMEWORK: ASP.NET Core or FastAPIPROJECT_ROOT: Project directory pathENVIRONMENT: Development or ProductionIdempotency Check:
GlobalExceptionMiddleware or UseExceptionHandler@app.exception_handler or exception_handlers.py{ "status": "skipped" }Use MCP tools to get up-to-date documentation.
For .NET:
MCP ref: "ASP.NET Core global exception handling middleware"
Context7: /dotnet/aspnetcore
For Python:
MCP ref: "FastAPI exception handlers custom exceptions"
Context7: /tiangolo/fastapi
Key Patterns to Research:
| Option | Description | |--------|-------------| | ProblemDetails (RFC 7807) (Recommended) | Standardized format, widely adopted | | Custom Format | Project-specific requirements |
| Environment | Stack Trace | Inner Exceptions | Request Details | |-------------|-------------|------------------|-----------------| | Development | ✓ Show | ✓ Show | ✓ Show | | Production | ✗ Hide | ✗ Hide | ✗ Hide |
Define standard error codes:
| Code | HTTP Status | Description |
|------|-------------|-------------|
| VALIDATION_ERROR | 400 | Invalid input data |
| UNAUTHORIZED | 401 | Authentication required |
| FORBIDDEN | 403 | Insufficient permissions |
| NOT_FOUND | 404 | Resource not found |
| CONFLICT | 409 | Resource state conflict |
| INTERNAL_ERROR | 500 | Unexpected server error |
| File | Purpose |
|------|---------|
| Middleware/GlobalExceptionMiddleware.cs | Exception handling middleware |
| Exceptions/AppException.cs | Base exception class |
| Exceptions/ValidationException.cs | Validation errors |
| Exceptions/NotFoundException.cs | Not found errors |
| Models/ErrorResponse.cs | Error response model |
Generation Process:
Registration Code:
app.UseMiddleware<GlobalExceptionMiddleware>();
| File | Purpose |
|------|---------|
| exceptions/app_exceptions.py | Custom exception classes |
| exceptions/handlers.py | FastAPI exception handlers |
| models/error_response.py | Pydantic error models |
Generation Process:
Registration Code:
app.add_exception_handler(AppException, app_exception_handler)
app.add_exception_handler(RequestValidationError, validation_exception_handler)
Validation Steps:
Syntax check:
dotnet build --no-restorepython -m py_compile exceptions/handlers.pyTest error handling:
Expected Error Response (ProblemDetails):
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "Validation Error",
"status": 400,
"detail": "Invalid input data",
"instance": "/api/users",
"errors": [
{ "field": "email", "message": "Invalid email format" }
],
"traceId": "abc-123-def-456"
}
{
"status": "success",
"files_created": [
"Middleware/GlobalExceptionMiddleware.cs",
"Exceptions/AppException.cs",
"Models/ErrorResponse.cs"
],
"packages_added": [],
"registration_code": "app.UseMiddleware<GlobalExceptionMiddleware>();",
"message": "Configured global exception handling"
}
GlobalExceptionMiddleware or exception_handlers.py exists, return status: "skipped"dotnet build or py_compile)Version: 2.0.0 Last Updated: 2026-01-10
testing
Drafts and publishes fact-checked GitHub Discussions announcements. Use for releases, updates, or project news; not for release creation or issue responses.
testing
Prepares and publishes a tagged GitHub release from repository evidence. Use for an explicit release request; not for ordinary commits, packages, or community news.
testing
Validates, commits, pushes, and remotely verifies approved repository changes. Use when publication is requested; not for releases, package publishing, or announcements.
development
Reviews standalone skills and their configured distribution surfaces before publication. Use for skill release readiness; not for product code or implementation-plan review.