Global Error Handling

Implement try-catch blocks, retry strategies, and user-friendly error messages across codebases.

Updated Mar 13, 2023
One-click install
npx skills add https://github.com/pdovhomilja/dovhomilja-cz --skill global-error-handling-pdovhomilja
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Global Error Handling
Source: https://github.com/pdovhomilja/dovhomilja-cz/tree/main/.claude/skills/global-error-handling
Command: npx skills add https://github.com/pdovhomilja/dovhomilja-cz --skill global-error-handling-pdovhomilja

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents application crashes and poor user experiences by ensuring errors are caught, handled gracefully, and communicated effectively without exposing sensitive technical details. It promotes a consistent and secure approach to error management.

Core Features & Use Cases

  • Graceful Degradation: Implement try-catch blocks, error boundaries, and retry strategies for robust error recovery.
  • User-Friendly Feedback: Generate clear, concise, and secure error messages for users, avoiding technical jargon.
  • Centralized Management: Establish consistent error handling at API or controller boundaries.
  • Use Case: When an external API call fails, this skill guides the AI to implement a retry mechanism with exponential backoff, display a user-friendly message on the frontend, and log the technical error securely on the backend without exposing it to the user.

Quick Start

Implement global error handling for the new user registration API endpoint, including a try-catch block, a user-friendly error message for invalid input, and secure logging.

Frequently Asked Questions about Global Error Handling

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

FAQPage Schema
How do I implement try-catch blocks to prevent API errors from crashing my application?

Try-catch blocks wrap code that might fail, capturing exceptions before they crash your app. Place them around API calls, database queries, and external service requests to catch errors, log them securely, and execute fallback logic or user-friendly messages instead of exposing technical details.

What's the best way to show error messages to users without revealing sensitive technical details?

Generate user-friendly error messages that describe what went wrong in simple terms, while logging full technical details server-side. Avoid exposing stack traces, database schema, or API internals to the frontend; instead communicate the impact and next steps users should take.

How do I handle external API failures with retry strategies and exponential backoff?

Implement retry logic that attempts failed API calls multiple times with increasing delays between attempts. Use exponential backoff to avoid overwhelming a failing service, set a maximum retry count, and fall back to graceful degradation or cached data if all retries exhaust.

Can I use error boundaries in React to catch and recover from component errors?

Error boundaries are React components that catch errors in child components, preventing full app crashes. They let you display fallback UI, log errors, and preserve app state in non-critical parts while isolating failures to specific sections of your interface.

Why should I centralize error handling at API and controller boundaries?

Centralized error handling enforces consistent validation, logging, and user messaging across your entire API. It catches errors before they propagate, prevents sensitive data leaks, standardizes exception types, and makes debugging easier by creating a single source of truth for error responses.