error-handling-patterns
Implement Robust Error Handling Patterns
Auch verfügbar von: wshobson
Build more resilient applications by mastering error handling patterns including exceptions, Result types, retry logic, and circuit breakers across Python, TypeScript, Rust, and Go.
Die Skill-ZIP herunterladen
In Claude hochladen
Gehe zu Einstellungen → Fähigkeiten → Skills → Skill hochladen
Einschalten und loslegen
Teste es
Verwendung von "error-handling-patterns". How do I handle errors when calling an external API?
Erwartetes Ergebnis:
For external API calls, implement multiple layers of error handling: (1) Custom exception hierarchy for different failure types, (2) Retry with exponential backoff for transient errors, (3) Circuit breaker to prevent cascading failures, (4) Graceful degradation with fallback data. Example approach: Create custom exceptions (NetworkError, TimeoutError, RateLimitError), wrap API calls in retry decorator with 3 attempts and exponential backoff, use circuit breaker to track failure rates, provide cached fallback when API is unavailable.
Verwendung von "error-handling-patterns". When should I use Result types instead of exceptions?
Erwartetes Ergebnis:
Use Result types for expected failures (validation errors, not found errors, business logic errors) where the caller should explicitly handle both success and failure cases. Use exceptions for truly exceptional situations (null pointers, out of memory, unexpected runtime errors). Result types make error handling explicit in the type system, forcing callers to consider failure cases. In TypeScript, Result<T, E> = { ok: true, value: T } | { ok: false, error: E }. In Rust, the ? operator and Result<T, E> type provide built-in support. This approach improves code readability and reduces unexpected runtime errors.
Sicherheitsaudit
SicherThis skill is a documentation and educational resource about error handling patterns. The static scanner flagged 49 potential issues, but after evaluation all findings are FALSE POSITIVES. The detected patterns (backtick syntax examples, HTTP library examples, error categories) are educational code snippets in markdown documentation, not executable malicious code. No security concerns identified.
Qualitätsbewertung
Was du bauen kannst
Improve Application Reliability
Add robust error handling to new or existing features with proper exception hierarchies and meaningful error messages.
Build Fault-Tolerant Systems
Implement retry logic, circuit breakers, and graceful degradation for distributed systems and microservices.
Learn Cross-Language Patterns
Understand error handling approaches across Python, TypeScript, Rust, and Go to choose the best approach for each situation.
Probiere diese Prompts
Help me implement proper error handling for a function that fetches user data from a database. I want to create custom exception classes and handle different error scenarios appropriately.
Show me how to implement a Result type pattern in TypeScript for parsing JSON data. Include proper error types and chainable error handling.
Create a Python decorator that implements retry logic with exponential backoff for network calls. Handle different exception types and include configurable attempts.
Implement a circuit breaker pattern in Python to prevent cascading failures when calling an external API. Include closed, open, and half-open states.
Bewährte Verfahren
- Fail fast by validating input early and providing meaningful error messages with context
- Preserve error context including stack traces, timestamps, and relevant metadata
- Handle errors at the appropriate level where you can meaningfully respond to them
- Log errors appropriately - log unexpected errors, not expected validation failures
Vermeiden
- Catching too broadly with generic Exception handlers that hide bugs
- Empty catch blocks that silently swallow errors without logging or handling
- Returning error codes instead of using proper exceptions or Result types
- Ignoring async errors by not handling promise rejections properly
Häufig gestellte Fragen
What is the difference between exceptions and Result types?
When should I use a circuit breaker?
How does exponential backoff work for retries?
What is graceful degradation?
Should I catch exceptions or let them propagate?
How do I create meaningful error messages?
Entwicklerdetails
Autor
sickn33Lizenz
MIT
Repository
https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/error-handling-patternsRef
main
Dateistruktur