Back to list
levnikolaevich

ln-772-error-handler-setup

by levnikolaevich

Greate Claude Code skills collection. Production-ready skills that cover the full delivery workflow — from research and discovery to epic planning, task breakdown, implementation, testing, code review, and quality gates.

52🍴 12📅 Jan 23, 2026

SKILL.md


name: ln-772-error-handler-setup description: Configures global exception handling middleware

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

AspectDetails
InputContext Store from ln-770
OutputException 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

OptionDescription
ProblemDetails (RFC 7807) (Recommended)Standardized format, widely adopted
Custom FormatProject-specific requirements

Q2: Error Detail Level

EnvironmentStack TraceInner ExceptionsRequest Details
Development✓ Show✓ Show✓ Show
Production✗ Hide✗ Hide✗ Hide

Q3: Error Taxonomy

Define standard error codes:

CodeHTTP StatusDescription
VALIDATION_ERROR400Invalid input data
UNAUTHORIZED401Authentication required
FORBIDDEN403Insufficient permissions
NOT_FOUND404Resource not found
CONFLICT409Resource state conflict
INTERNAL_ERROR500Unexpected server error

Phase 4: Generate Configuration

.NET Output Files

FilePurpose
Middleware/GlobalExceptionMiddleware.csException handling middleware
Exceptions/AppException.csBase exception class
Exceptions/ValidationException.csValidation errors
Exceptions/NotFoundException.csNot found errors
Models/ErrorResponse.csError 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
  3. Generate custom exception classes

Registration Code:

app.UseMiddleware<GlobalExceptionMiddleware>();

Python Output Files

FilePurpose
exceptions/app_exceptions.pyCustom exception classes
exceptions/handlers.pyFastAPI exception handlers
models/error_response.pyPydantic 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
  3. Generate custom exception classes

Registration Code:

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
  2. Test error handling:

    • Create test endpoint that throws exception
    • Verify error response format
    • Check that stack trace hidden in Production

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

Return to Coordinator

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


Version: 2.0.0 Last Updated: 2026-01-10

Score

Total Score

80/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

+10
人気

GitHub Stars 100以上

0/15
最近の活動

1ヶ月以内に更新

+10
フォーク

10回以上フォークされている

+5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

+5

Reviews

💬

Reviews coming soon