🎯

ln-772-error-handler-setup

🎯Skill

from levnikolaevich/claude-code-skills

VibeIndex|
What it does

Configures global exception handling middleware for .NET and Python backend applications with standardized error responses.

πŸ“¦

Part of

levnikolaevich/claude-code-skills(85 items)

ln-772-error-handler-setup

Installation

Claude CodeAdd plugin in Claude Code
/plugin add levnikolaevich/claude-code-skills
git cloneClone repository
git clone https://github.com/levnikolaevich/claude-code-skills.git ~/.claude/skills
πŸ“– Extracted from docs: levnikolaevich/claude-code-skills
13Installs
-
AddedFeb 4, 2026

Skill Details

SKILL.md

Configures global exception handling middleware

Overview

# ln-772-error-handler-setup

Type: L3 Worker

Category: 7XX Project Bootstrap

Parent: ln-770-crosscutting-setup

Configures global error handling for .NET and Python backend applications.

---

Overview

| 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) |

---

Phase 1: Receive Context

Accept Context Store from coordinator.

Required Context:

  • STACK: .NET or Python
  • FRAMEWORK: ASP.NET Core or FastAPI
  • PROJECT_ROOT: Project directory path
  • ENVIRONMENT: Development or Production

Idempotency Check:

  • .NET: Grep for GlobalExceptionMiddleware or UseExceptionHandler
  • Python: Grep for @app.exception_handler or exception_handlers.py
  • If found: Return { "status": "skipped" }

---

Phase 2: Research Error Handling Patterns

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:

  1. Middleware pipeline positioning
  2. Exception type mapping to HTTP status codes
  3. ProblemDetails (RFC 7807) format
  4. Development vs Production error details
  5. Logging integration

---

Phase 3: Decision Points

Q1: Error Response Format

| Option | Description |

|--------|-------------|

| ProblemDetails (RFC 7807) (Recommended) | Standardized format, widely adopted |

| Custom Format | Project-specific requirements |

Q2: Error Detail Level

| Environment | Stack Trace | Inner Exceptions | Request Details |

|-------------|-------------|------------------|-----------------|

| Development | βœ“ Show | βœ“ Show | βœ“ Show |

| Production | βœ— Hide | βœ— Hide | βœ— Hide |

Q3: Error Taxonomy

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 |

---

Phase 4: Generate Configuration

.NET Output Files

| 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:

  1. Use MCP ref to get current ASP.NET Core exception handling patterns
  2. Generate GlobalExceptionMiddleware with:

- Exception type to HTTP status mapping

- Logging of exceptions

- ProblemDetails response format

- Environment-aware detail level

  1. Generate custom exception classes

Registration Code:

```csharp

app.UseMiddleware();

```

Python Output Files

| File | Purpose |

|------|---------|

| exceptions/app_exceptions.py | Custom exception classes |

| exceptions/handlers.py | FastAPI exception handlers |

| models/error_response.py | Pydantic error models |

Generation Process:

  1. Use MCP ref to get current FastAPI exception handling patterns
  2. Generate exception handlers with:

- HTTPException handling

- Custom AppException handling

- Validation error handling

- Request validation error handling

  1. Generate custom exception classes

Registration Code:

```python

app.add_exception_handler(AppException, app_exception_handler)

app.add_exception_handler(RequestValidationError, validation_exception_handler)

```

---

Phase 5: Validate

Validation Steps:

  1. Syntax check:

- .NET: dotnet build --no-restore

- Python: python -m py_compile exceptions/handlers.py

  1. Test error handling:

- Create test endpoint that throws exception

- Verify error response format

- Check that stack trace hidden in Production

Expected Error Response (ProblemDetails):

```json

{

"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"

}

```

---

Return to Coordinator

```json

{

"status": "success",

"files_created": [

"Middleware/GlobalExceptionMiddleware.cs",

"Exceptions/AppException.cs",

"Models/ErrorResponse.cs"

],

"packages_added": [],

"registration_code": "app.UseMiddleware();",

"message": "Configured global exception handling"

}

```

---

Reference Links

  • [ASP.NET Core Error Handling](https://learn.microsoft.com/aspnet/core/web-api/handle-errors)
  • [FastAPI Handling Errors](https://fastapi.tiangolo.com/tutorial/handling-errors/)
  • [RFC 7807 Problem Details](https://tools.ietf.org/html/rfc7807)

---

Version: 2.0.0

Last Updated: 2026-01-10

More from this repository10

πŸͺ
levnikolaevich-claude-code-skillsπŸͺMarketplace

Official marketplace for Agile Linear Workflow plugin - complete end-to-end automation for software development teams using Linear. Includes 7XX Project Bootstrap series for technology-agnostic project migration.

🎯
ln-140-test-docs-creator🎯Skill

Generates comprehensive test documentation with testing strategy and test organization structure for software projects.

🎯
ln-110-project-docs-coordinator🎯Skill

Coordinates project documentation by gathering context once, detecting project type, and delegating document creation to 5 specialized workers.

🎯
ln-114-frontend-docs-creator🎯Skill

Generates design guidelines documentation for frontend projects with WCAG 2.1 compliance when a frontend framework is detected.

🎯
ln-113-backend-docs-creator🎯Skill

Generates backend documentation files (API spec and database schema) automatically when backend or database technologies are detected in a project.

🎯
ln-610-code-comments-auditor🎯Skill

Audits code comments and docstrings across 6 quality categories, generating a comprehensive compliance score and actionable recommendations for improvement.

🎯
ln-115-devops-docs-creator🎯Skill

Generates a comprehensive runbook.md for DevOps setup, dynamically tailored to project's Docker configuration and deployment specifics.

🎯
ln-120-reference-docs-creator🎯Skill

Generates reference documentation structure and smart documents for project tech stack, creating only justified architectural decision records and guides.

🎯
ln-626-dead-code-auditor🎯Skill

Identifies and reports dead, unused, and legacy code across the codebase, generating a comprehensive audit with compliance scoring.

🎯
ln-111-root-docs-creator🎯Skill

Generates standardized root documentation files for a project using templates and context-specific data from a coordinator.