{
    "url": "https://delaparra-services.nl/skills/error-handling-patterns",
    "locale": "en",
    "title": "Error Handling Patterns | DeLaParra Services",
    "description": "Master error handling patterns across languages including exceptions, Result types, error propagation, and graceful degradation to build resilient applications. Use when implementing error handling, designing APIs, or improving application reliability.",
    "alternates": {
        "en": "https://delaparra-services.nl/skills/error-handling-patterns",
        "nl": "https://delaparra-services.nl/nl/skills/error-handling-patterns"
    },
    "formats": {
        "csv": "https://delaparra-services.nl/skills/error-handling-patterns.csv",
        "md": "https://delaparra-services.nl/skills/error-handling-patterns.md",
        "json": "https://delaparra-services.nl/skills/error-handling-patterns.json",
        "zip": "https://delaparra-services.nl/skills/error-handling-patterns.zip",
        "pdf": "https://delaparra-services.nl/skills/error-handling-patterns.pdf"
    },
    "downloads": [
        {
            "url": "https://delaparra-services.nl/skills/error-handling-patterns.csv",
            "encodingFormat": "text/csv",
            "name": "error-handling-patterns.csv"
        },
        {
            "url": "https://delaparra-services.nl/skills/error-handling-patterns.json",
            "encodingFormat": "application/json",
            "name": "error-handling-patterns.json"
        },
        {
            "url": "https://delaparra-services.nl/skills/error-handling-patterns.md",
            "encodingFormat": "text/markdown",
            "name": "error-handling-patterns.md"
        },
        {
            "url": "https://delaparra-services.nl/skills/error-handling-patterns.pdf",
            "encodingFormat": "application/pdf",
            "name": "error-handling-patterns.pdf"
        },
        {
            "url": "https://delaparra-services.nl/skills/error-handling-patterns.zip",
            "encodingFormat": "application/zip",
            "name": "error-handling-patterns.zip"
        },
        {
            "url": "https://delaparra-services.nl/skills/error-handling-patterns/download",
            "encodingFormat": "application/zip",
            "name": "error-handling-patterns-files.zip"
        }
    ],
    "markdown": "# Error Handling Patterns\n\n \n\nMaster error handling patterns across languages including exceptions, Result types, error propagation, and graceful degradation to build resilient applications. Use when implementing error handling, designing APIs, or improving application reliability.\n\n \n\n**Licence** MIT\n\n \n\n**Source** wshobson/agents\n\n [Download zip](<https://delaparra-services.nl/skills/error-handling-patterns/download>)   \n\n# Error Handling Patterns\n\n \n\nBuild resilient applications with robust error handling strategies that gracefully handle failures and provide excellent debugging experiences.\n\n \n\n## When to Use This Skill\n\n \n\n- Implementing error handling in new features \n- Designing error-resilient APIs \n- Debugging production issues \n- Improving application reliability \n- Creating better error messages for users and developers \n- Implementing retry and circuit breaker patterns \n- Handling async/concurrent errors \n- Building fault-tolerant distributed systems\n\n \n\n## Core Concepts\n\n \n\n### 1. Error Handling Philosophies\n\n \n\n**Exceptions vs Result Types:**\n\n \n\n- **Exceptions**: Traditional try-catch, disrupts control flow \n- **Result Types**: Explicit success/failure, functional approach \n- **Error Codes**: C-style, requires discipline \n- **Option/Maybe Types**: For nullable values\n\n \n\n**When to Use Each:**\n\n \n\n- Exceptions: Unexpected errors, exceptional conditions \n- Result Types: Expected errors, validation failures \n- Panics/Crashes: Unrecoverable errors, programming bugs\n\n \n\n### 2. Error Categories\n\n \n\n**Recoverable Errors:**\n\n \n\n- Network timeouts \n- Missing files \n- Invalid user input \n- API rate limits\n\n \n\n**Unrecoverable Errors:**\n\n \n\n- Out of memory \n- Stack overflow \n- Programming bugs (null pointer, etc.)\n\n \n\n## Detailed patterns and worked examples\n\n \n\nDetailed pattern documentation lives in ` references/details.md `. Read that file when the navigation tier above is insufficient.\n\n \n\n## Best Practices\n\n \n\n1. **Fail Fast**: Validate input early, fail quickly \n1. **Preserve Context**: Include stack traces, metadata, timestamps \n1. **Meaningful Messages**: Explain what happened and how to fix it \n1. **Log Appropriately**: Error = log, expected failure = don't spam logs \n1. **Handle at Right Level**: Catch where you can meaningfully handle \n1. **Clean Up Resources**: Use try-finally, context managers, defer \n1. **Don't Swallow Errors**: Log or re-throw, don't silently ignore \n1. **Type-Safe Errors**: Use typed errors when possible\n\n \n\n```\n# Good error handling example\ndef process_order(order_id: str) -> Order:\n    \"\"\"Process order with comprehensive error handling.\"\"\"\n    try:\n        # Validate input\n        if not order_id:\n            raise ValidationError(\"Order ID is required\")\n\n        # Fetch order\n        order = db.get_order(order_id)\n        if not order:\n            raise NotFoundError(\"Order\", order_id)\n\n        # Process payment\n        try:\n            payment_result = payment_service.charge(order.total)\n        except PaymentServiceError as e:\n            # Log and wrap external service error\n            logger.error(f\"Payment failed for order {order_id}: {e}\")\n            raise ExternalServiceError(\n                f\"Payment processing failed\",\n                service=\"payment_service\",\n                details={\"order_id\": order_id, \"amount\": order.total}\n            ) from e\n\n        # Update order\n        order.status = \"completed\"\n        order.payment_id = payment_result.id\n        db.save(order)\n\n        return order\n\n    except ApplicationError:\n        # Re-raise known application errors\n        raise\n    except Exception as e:\n        # Log unexpected errors\n        logger.exception(f\"Unexpected error processing order {order_id}\")\n        raise ApplicationError(\n            \"Order processing failed\",\n            code=\"INTERNAL_ERROR\"\n        ) from e\n```\n\n \n\n## Common Pitfalls\n\n \n\n- **Catching Too Broadly**: ` except Exception ` hides bugs \n- **Empty Catch Blocks**: Silently swallowing errors \n- **Logging and Re-throwing**: Creates duplicate log entries \n- **Not Cleaning Up**: Forgetting to close files, connections \n- **Poor Error Messages**: \"Error occurred\" is not helpful \n- **Returning Error Codes**: Use exceptions or Result types \n- **Ignoring Async Errors**: Unhandled promise rejections\n\n \n\n## Files\n\n \n\n- ` LICENSE ` \n- ` SKILL.md ` \n- ` SOURCE.md ` \n- ` references/details.md `\n\n \n\n## Related terms\n\n \n\n- [Actor](<https://delaparra-services.nl/knowledge-hub/actor>) \n- [Actor Model](<https://delaparra-services.nl/knowledge-hub/actor-model>) \n- [Asynchronous](<https://delaparra-services.nl/knowledge-hub/asynchronous>) \n- [Atomic Operation](<https://delaparra-services.nl/knowledge-hub/atomic-operation>) \n- [AttributeError](<https://delaparra-services.nl/knowledge-hub/attributeerror>) \n- [Backpressure](<https://delaparra-services.nl/knowledge-hub/backpressure>) \n- [Data Parallelism](<https://delaparra-services.nl/knowledge-hub/data-parallelism>) \n- [Deadlock](<https://delaparra-services.nl/knowledge-hub/deadlock>) \n- [Event Loop](<https://delaparra-services.nl/knowledge-hub/event-loop>) \n- [IndexOutOfBoundsException](<https://delaparra-services.nl/knowledge-hub/indexoutofboundsexception>) \n- [KeyError](<https://delaparra-services.nl/knowledge-hub/keyerror>) \n- [log](<https://delaparra-services.nl/knowledge-hub/log>) \n- [Mailbox](<https://delaparra-services.nl/knowledge-hub/mailbox>) \n- [Message Passing](<https://delaparra-services.nl/knowledge-hub/message-passing>) \n- [Message Queue](<https://delaparra-services.nl/knowledge-hub/message-queue>) \n- [Mutex (Mutual Exclusion)](<https://delaparra-services.nl/knowledge-hub/mutex-mutual-exclusion>) \n- [Mutex / Lock](<https://delaparra-services.nl/knowledge-hub/mutex-lock>) \n- [NullPointerException](<https://delaparra-services.nl/knowledge-hub/nullpointerexception>) \n- [OutOfMemoryError](<https://delaparra-services.nl/knowledge-hub/outofmemoryerror>) \n- [Queue](<https://delaparra-services.nl/knowledge-hub/queue>) \n- [Race condition](<https://delaparra-services.nl/knowledge-hub/race-condition>) \n- [Race Condition](<https://delaparra-services.nl/knowledge-hub/race-condition-paradigms>) \n- [ReferenceError](<https://delaparra-services.nl/knowledge-hub/referenceerror>) \n- [RuntimeError](<https://delaparra-services.nl/knowledge-hub/runtimeerror>) \n- [SegmentationFault](<https://delaparra-services.nl/knowledge-hub/segmentationfault>) \n- [StackOverflowError](<https://delaparra-services.nl/knowledge-hub/stackoverflowerror>) \n- [structured logging](<https://delaparra-services.nl/knowledge-hub/structured-logging>) \n- [Supervision](<https://delaparra-services.nl/knowledge-hub/supervision>) \n- [SyntaxError](<https://delaparra-services.nl/knowledge-hub/syntaxerror>) \n- [Thread](<https://delaparra-services.nl/knowledge-hub/thread>) \n- [TypeError](<https://delaparra-services.nl/knowledge-hub/typeerror>) \n- [ValueError](<https://delaparra-services.nl/knowledge-hub/valueerror>) \n- [ZeroDivisionError](<https://delaparra-services.nl/knowledge-hub/zerodivisionerror>)\n\n \n\n[Installing an agent skill in Claude Code, Codex, Cursor and Copilot](<https://delaparra-services.nl/manuals/een-skill-installeren-in-je-ai-assistent>)\n\n[HTML version](https://delaparra-services.nl/skills/error-handling-patterns)\n",
    "structured_data": {
        "@context": "https://schema.org",
        "@graph": [
            {
                "@type": "Organization",
                "@id": "https://delaparra-services.nl/#practice",
                "logo": "https://delaparra-services.nl/logo.png",
                "name": "DeLaParra Services",
                "legalName": "DeLaParra Services",
                "url": "https://delaparra-services.nl/",
                "description": "Bespoke software, web applications and mobile apps, developed in Laravel by a single developer in Groningen. Fixed price agreed in advance, full source code provided upon delivery.",
                "email": "info@delaparra-services.nl",
                "address": {
                    "@type": "PostalAddress",
                    "addressLocality": "Groningen",
                    "addressRegion": "Groningen",
                    "addressCountry": "NL"
                },
                "areaServed": "Groningen, the Netherlands",
                "knowsLanguage": [
                    "en",
                    "nl"
                ],
                "knowsAbout": [
                    "Web design and development",
                    "App development",
                    "Custom software and web applications",
                    "OpenSpec",
                    "AI code review",
                    "Your own coding agent"
                ],
                "founder": {
                    "@id": "https://delaparra-services.nl/#person"
                }
            },
            {
                "@type": "WebPage",
                "@id": "https://delaparra-services.nl/skills/error-handling-patterns#webpage",
                "url": "https://delaparra-services.nl/skills/error-handling-patterns",
                "name": "Error Handling Patterns | DeLaParra Services",
                "description": "Master error handling patterns across languages including exceptions, Result types, error propagation, and graceful degradation to build resilient applications. Use when implementing error handling, designing APIs, or improving application reliability.",
                "isPartOf": {
                    "@id": "https://delaparra-services.nl/#website"
                },
                "about": {
                    "@id": "https://delaparra-services.nl/#practice"
                },
                "inLanguage": "en",
                "breadcrumb": {
                    "@id": "https://delaparra-services.nl/skills/error-handling-patterns#breadcrumb"
                }
            },
            {
                "@type": "BreadcrumbList",
                "@id": "https://delaparra-services.nl/skills/error-handling-patterns#breadcrumb",
                "itemListElement": [
                    {
                        "@type": "ListItem",
                        "position": 1,
                        "name": "Home",
                        "item": "https://delaparra-services.nl/"
                    },
                    {
                        "@type": "ListItem",
                        "position": 2,
                        "name": "Error Handling Patterns"
                    }
                ]
            },
            {
                "@type": "Person",
                "@id": "https://delaparra-services.nl/#person",
                "name": "Reinier de la Parra",
                "url": "https://delaparra-services.nl/about"
            },
            {
                "@type": "SoftwareSourceCode",
                "@id": "https://delaparra-services.nl/skills/error-handling-patterns#skill",
                "url": "https://delaparra-services.nl/skills/error-handling-patterns",
                "name": "Error Handling Patterns",
                "description": "Master error handling patterns across languages including exceptions, Result types, error propagation, and graceful degradation to build resilient applications. Use when implementing error handling, designing APIs, or improving application reliability.",
                "inLanguage": "en",
                "license": "https://spdx.org/licenses/MIT.html",
                "subjectOf": {
                    "@id": "https://delaparra-services.nl/skills/error-handling-patterns#dataset"
                }
            },
            {
                "@type": "Dataset",
                "@id": "https://delaparra-services.nl/skills/error-handling-patterns#dataset",
                "name": "Error Handling Patterns",
                "description": "Master error handling patterns across languages including exceptions, Result types, error propagation, and graceful degradation to build resilient applications. Use when implementing error handling, designing APIs, or improving application reliability.",
                "url": "https://delaparra-services.nl/skills/error-handling-patterns",
                "identifier": "https://delaparra-services.nl/skills/error-handling-patterns#dataset",
                "about": {
                    "@id": "https://delaparra-services.nl/skills/error-handling-patterns#skill"
                },
                "creditText": "wshobson/agents",
                "publisher": {
                    "@id": "https://delaparra-services.nl/#practice"
                },
                "license": "https://spdx.org/licenses/MIT.html",
                "isAccessibleForFree": true,
                "inLanguage": "en",
                "dateModified": "2026-11-28T14:00:11+00:00",
                "isPartOf": {
                    "@type": "Dataset",
                    "@id": "https://delaparra-services.nl/knowledge-hub#skills",
                    "name": "Skills for AI coding assistants",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "includedInDataCatalog": {
                    "@type": "DataCatalog",
                    "@id": "https://delaparra-services.nl/knowledge-hub#catalog",
                    "name": "Knowledge hub data catalog",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "distribution": [
                    {
                        "@type": "DataDownload",
                        "name": "error-handling-patterns.csv",
                        "encodingFormat": "text/csv",
                        "contentUrl": "https://delaparra-services.nl/skills/error-handling-patterns.csv",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T14:00:11+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "error-handling-patterns.json",
                        "encodingFormat": "application/json",
                        "contentUrl": "https://delaparra-services.nl/skills/error-handling-patterns.json",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T14:00:11+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "error-handling-patterns.md",
                        "encodingFormat": "text/markdown",
                        "contentUrl": "https://delaparra-services.nl/skills/error-handling-patterns.md",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T14:00:11+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "error-handling-patterns.pdf",
                        "encodingFormat": "application/pdf",
                        "contentUrl": "https://delaparra-services.nl/skills/error-handling-patterns.pdf",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T14:00:11+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "error-handling-patterns.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/skills/error-handling-patterns.zip",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T14:00:11+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "error-handling-patterns-files.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/skills/error-handling-patterns/download",
                        "inLanguage": "en",
                        "dateModified": "2026-11-28T14:00:11+00:00",
                        "license": "https://spdx.org/licenses/MIT.html"
                    }
                ]
            }
        ]
    }
}