Loading...
Loading...
Configures global exception handling middleware
npx skill4agent add levnikolaevich/claude-code-skills ln-772-error-handler-setup| 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) |
STACKFRAMEWORKPROJECT_ROOTENVIRONMENTGlobalExceptionMiddlewareUseExceptionHandler@app.exception_handlerexception_handlers.py{ "status": "skipped" }MCP ref: "ASP.NET Core global exception handling middleware"
Context7: /dotnet/aspnetcoreMCP ref: "FastAPI exception handlers custom exceptions"
Context7: /tiangolo/fastapi| 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 |
| Code | HTTP Status | Description |
|---|---|---|
| 400 | Invalid input data |
| 401 | Authentication required |
| 403 | Insufficient permissions |
| 404 | Resource not found |
| 409 | Resource state conflict |
| 500 | Unexpected server error |
| File | Purpose |
|---|---|
| Exception handling middleware |
| Base exception class |
| Validation errors |
| Not found errors |
| Error response model |
app.UseMiddleware<GlobalExceptionMiddleware>();| File | Purpose |
|---|---|
| Custom exception classes |
| FastAPI exception handlers |
| Pydantic error models |
app.add_exception_handler(AppException, app_exception_handler)
app.add_exception_handler(RequestValidationError, validation_exception_handler)dotnet build --no-restorepython -m py_compile exceptions/handlers.py{
"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"
}