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
Audits architecture config boundaries: typed settings, scattered env reads, config leakage, and layer ownership. Use for config architecture.
tools
Finds architecture-level modernization opportunities: obsolete custom mechanisms, overbuilt extension points, and simplifiable architecture. Use when auditing architecture evolution.
development
Builds dependency topology, detects cycles, validates import rules, and calculates coupling metrics. Use when auditing architecture topology.
testing
Checks layer, resource ownership, and orchestration boundaries. Use when auditing architecture boundary enforcement.