error-handling

Implement structured error handling patterns for Next.js frontend and backend.

Updated Jan 26, 2026
One-click install
npx skills add https://github.com/theofernandezz/ai-library --skill error-handling-theofernandezz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: error-handling
Source: https://github.com/theofernandezz/ai-library/tree/main/.opencode/skills/error-handling
Command: npx skills add https://github.com/theofernandezz/ai-library --skill error-handling-theofernandezz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Developers often struggle to keep error behavior consistent across UI, API routes, and services. This skill provides a cohesive, battle-tested framework for defining and enforcing structured errors, boundaries, and recovery patterns.

Core Features & Use Cases

  • Custom error classes with codes and status
  • Server action and API route error handling
  • React error boundaries and a global fallback
  • Structured logging and safe asynchronous wrappers
  • Retry and backoff utilities for transient failures

Quick Start

Integrate the provided error types, boundaries, and utilities into your Next.js app to standardize error handling across UI and API layers.

Frequently Asked Questions about error-handling

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

FAQPage Schema
How do I standardize error handling across Next.js server actions and UI components?

Standardizing error handling involves implementing custom error classes with specific codes and status mappings alongside React error boundaries. This framework ensures cohesive error management from API routes to the frontend.

What is the best way to handle transient failures and timeouts in API routes?

The best way to handle transient failures is by applying retry and backoff utilities combined with safe asynchronous wrappers. This pattern automatically retries failed operations and manages transient errors without crashing the server.

How do you implement structured logging for frontend and backend exceptions?

Implementing structured logging involves integrating a utility that captures custom error classes and contextual details across frontend and backend layers. This provides consistent error tracking and debugging context for server actions.

Does this error management framework work for SaaS apps with global error boundaries?

Yes, this framework is designed for SaaS apps and includes a global error boundary fallback. It effectively catches unexpected UI crashes and provides user-friendly error states across the application.

Why do I need custom error classes instead of standard exceptions for server actions?

Custom error classes are needed because they attach specific error codes and HTTP status properties to the exception. This allows server actions to return structured, predictable responses rather than generic runtime exceptions.

Can I use async wrappers to catch unhandled promise rejections in React?

Yes, you can use safe asynchronous wrappers to catch unhandled promise rejections before they reach the UI. These wrappers securely execute async functions and pass caught exceptions to error boundaries or logging utilities.