error-handling-patterns

Implement consistent error hierarchies, API error responses, and logging integration across applications.

Updated Mar 30, 2026
One-click install
npx skills add https://github.com/rubrical-works/idpf-praxis-skills --skill error-handling-patterns-rubrical-works
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: error-handling-patterns
Source: https://github.com/rubrical-works/idpf-praxis-skills/tree/main/Skills/error-handling-patterns
Command: npx skills add https://github.com/rubrical-works/idpf-praxis-skills --skill error-handling-patterns-rubrical-works

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Applications often suffer from inconsistent error handling: ad-hoc exceptions, unclear API error responses, leaked internal details, and missing log context. This Skill provides structured patterns for designing error hierarchies, standardizing API error responses, and integrating error logging so failures are diagnosable and safe. ## Core Features & Use Cases - Error Hierarchy Design: Base error classes with categories for validation, not-found, authorization, business logic, and external service errors, with examples in Python, JavaScript, Go, Rust, and Java. - API Error Responses: Standard JSON error formats, HTTP status code mapping, error code naming conventions, and separation of user-facing versus developer-facing messages. - Logging Integration: Structured logging patterns, sensitive data redaction, correlation IDs, metrics, and alert rules for monitoring. - Use Case: When building a REST API, apply the hierarchy and response patterns so a validation failure returns a consistent 400 JSON body with an error code, while unexpected exceptions are logged with stack traces and return a safe 500 response. ## Quick Start Ask Claude to read the error-handling-patterns SKILL.md and design an error hierarchy with standardized API error responses for your project.

Frequently Asked Questions about error-handling-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design an error hierarchy for my application?▼

Create a base AppError class carrying a code, message, and details, then subclass it by category such as ValidationError, NotFoundError, AuthorizationError, BusinessError, and ExternalServiceError. The skill documents domain-based, HTTP-based, layer-based, and severity-based hierarchy patterns.

What HTTP status code should API errors return?▼

Map validation errors to 400, authentication failures to 401, authorization failures to 403, missing resources to 404, business rule conflicts to 409, rate limits to 429, and unexpected server errors to 500. Use 422 for semantically invalid requests and 502 or 503 for downstream service failures.

How should API error responses be formatted in JSON?▼

Use a consistent envelope with an error object containing a machine-readable code, human-readable message, details object, and request ID. The skill covers simple custom formats, JSON:API style, and RFC 7807 Problem Details, plus nested and multi-field validation error structures.

What should never be included in error logs or responses?▼

Never log passwords, API keys, tokens, credit card numbers, or other PII, and never expose stack traces or internal exception details in client-facing 500 responses. Return a generic INTERNAL_ERROR code with a request ID while logging full details server-side.

Does this error handling guidance work with Go and Rust?▼

Yes. The skill includes Go patterns using explicit error returns with errors.Is and error wrapping, and Rust patterns using Result types, the ? operator, and thiserror-derived error enums, alongside Python, JavaScript, and Java examples.

When should I use resilience patterns instead of error handling patterns?▼

Error handling defines what errors look like and how they are reported, while resilience patterns define what to do when errors occur at system boundaries. Use this skill for error types and responses, and the complementary resilience-patterns skill for retry, circuit breaker, and timeout behavior.