agentsclimarketplace

Error handling

Skill iceflower/agent-skills/error-handling

Agent Skills 오픈 표준 기반 AI 코딩 에이전트용 스킬 컬렉션 (Java, Kotlin, Spring, NestJS, K8s, Terraform, GraphQL, gRPC, OpenTelemetry, a11y, i18n 등 60개)

Install
npx -y skills add iceflower/agent-skills --skill error-handling

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Framework-agnostic error handling patterns including exception hierarchy, error classification, response format, and handling principles. Use when designing error handling strategies.

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

5.3 KB, as published. Nobody here has run it

Error Handling Rules

1. Exception Hierarchy

Business vs System Exceptions

CategoryCharacteristicsHTTP Status RangeLog Level
Business exceptionExpected, recoverable by caller4xxWARN or INFO
System exceptionUnexpected, programming bug or I/O5xxERROR

Error Classification

TypeExamplesRecommended Action
RecoverableInvalid input, network timeoutSignal to caller, allow retry
UnrecoverableProgramming bug, corrupted stateFail fast, log and alert
External faultUpstream API error, DNS failureWrap in domain exception, retry

2. Error Response Format

Standard JSON Structure

{
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "User not found: 42",
    "details": [
      {
        "field": "userId",
        "message": "No user exists with the given ID"
      }
    ]
  },
  "meta": {
    "timestamp": "2024-01-15T10:30:45.123Z",
    "requestId": "abc-123-def"
  }
}

Response Format Rules

  • Use a consistent error envelope across all endpoints
  • Include a machine-readable error code (not just HTTP status)
  • Include a human-readable message for debugging
  • Include field-level details for validation errors
  • Include requestId/traceId for correlation

3. Exception Handling Principles

Do

  • Catch at the appropriate layer (controller for HTTP, service for business logic)
  • Always include context in exception messages (entity name, ID, field)
  • Log stack traces for system exceptions
  • Use error code enums for consistent codes across the application
  • Include traceId in error responses for debugging

Do Not

  • Catch exceptions broadly in service/repository layers
  • Expose internal details (stack traces, SQL, class names) in API responses
  • Use exceptions for flow control (e.g., throwing NotFoundException to check existence)
  • Swallow exceptions silently (empty catch blocks)
  • Log sensitive data in exception messages (passwords, tokens, PII)

4. Layer-Specific Guidelines

Controller Layer

  • Do not handle exceptions directly — delegate to a centralized exception handler
  • Validate request inputs at the API boundary before passing to service layer

Service Layer

  • Throw business exception subtypes for business rule violations
  • Wrap external API failures in domain-specific exceptions
  • Use explicit try-catch only for recoverable operations

Repository / Data Layer

  • Let data access exceptions propagate to the service layer
  • Do not catch data access exceptions unless specific recovery logic exists

5. External API Error Handling

Principles

  • Never let raw HTTP client exceptions propagate to callers
  • Wrap in domain-specific exceptions (e.g., PaymentApiException)
  • Log response status and body on errors (but mask sensitive data)
  • Distinguish between retryable (network, 503) and non-retryable (400, 404) errors

Error Wrapping Strategy

Exception SourceCauseAction
HTTP response error4xx/5xx responseMap to domain error
Network/timeout errorConnection failureRetry or circuit break
Parsing/decoding errorMalformed responseLog and fail

6. Anti-Patterns

  • Catching generic Exception in every method
  • Returning error details in success response fields
  • Using HTTP 200 for all responses with error codes in body
  • Inconsistent error response formats across endpoints
  • Missing error codes (only HTTP status, no application code)
  • Logging errors without stack traces
  • Retrying on non-idempotent failures without safeguards
  • Pokemon Exception Handling: Catching all exceptions with a generic catch-all. Use specific exception types instead
  • Error Swallowing: Empty catch blocks make debugging impossible. Always log or propagate errors
  • Exceptions as Flow Control: Using exceptions for normal program flow degrades performance and readability

Additional References

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.