#error-handling
24 snippets tagged with #error-handling
Async Error Handler Wrapper
Higher-order function that wraps async Express route handlers and forwards rejected promises to error middleware.
Best for: Express route error handling
Express Error Handling Middleware
Centralized error handling in Express with custom error classes, async wrapper, and structured responses.
Best for: API error standardization
Retry with Exponential Backoff
Retry failed async operations with exponential backoff, jitter, and configurable retry conditions.
Best for: API call resilience
Error Boundary with Fallback UI
Class-based error boundary component that catches render errors and displays a customizable fallback UI.
Best for: Graceful error recovery
React Error Boundary Component
Build a reusable error boundary with retry, fallback UI, and error reporting integration.
Best for: Preventing full-page crashes from component errors
Error Boundary with Fallback UI
Error boundary class component with customizable fallback UI, retry button, and error reporting.
Best for: Graceful error recovery
Next.js Error Handling Patterns
Implement error.tsx, not-found.tsx, and global-error.tsx for comprehensive error handling.
Best for: Graceful error recovery in nested layouts
Error Handling with error.tsx and not-found.tsx
Handle errors gracefully with error.tsx boundaries and not-found.tsx pages in App Router.
Best for: error boundaries
Retry Decorator with Exponential Backoff
Generic retry decorator with configurable attempts, exponential backoff, and exception filtering.
Best for: Network request resilience
Tenacity Retry with Backoff
Add robust retry logic with exponential backoff, jitter, and conditional retry using the tenacity library.
Best for: Flaky API calls
Retry Logic for Data Pipelines
Configurable retry decorator with exponential backoff and jitter for resilient data pipeline tasks.
Best for: Resilient API calls in data pipelines
Spring Boot Global Exception Handler
Centralized error handling with @ControllerAdvice for validation errors, 404s, and custom exceptions.
Best for: Consistent error responses across all endpoints
Custom Exception Hierarchy
Design a clean exception hierarchy with custom exceptions, error codes, and exception mapping.
Best for: Consistent error handling across services
Retry Mechanism with Exponential Backoff
Implement retries with exponential backoff, jitter, max attempts, and exception-specific handling.
Best for: Resilient API calls with transient failure handling
Result Monad — Functional Error Handling
Handle errors functionally with Kotlin Result: map, recover, fold, and chaining fallible operations.
Best for: Type-safe error handling without exceptions
Coroutine Exception Handling and Supervision
Handle errors in coroutines: CoroutineExceptionHandler, supervisorScope, try-catch, and error propagation.
Best for: Robust error handling in concurrent operations
Preconditions — require, check, and error
Validate inputs and state with Kotlin preconditions: require, check, error, and custom assertions.
Best for: Input validation at function boundaries
Functional Error Handling with Either
Use Either and Option for type-safe error handling: Railway-oriented programming without exceptions.
Best for: Type-safe error handling without exceptions
SupervisorJob and Error Isolation
Isolate coroutine failures with SupervisorJob: independent child coroutines, partial failure handling.
Best for: Independent failure isolation in microservices
Functional Error Handling with Either
Implement Either monad for type-safe error handling with map, flatMap, and fold operations.
Best for: Type-safe error handling without exceptions
Kotlin Result API Functional Error Handling
Use Kotlin's built-in Result type for functional error handling: runCatching, map, recover, and fold.
Best for: Functional error handling without try-catch
Kotlin Error Handling Patterns
Comprehensive error handling: sealed result types, validated aggregation, and railway-oriented programming.
Best for: Form validation with error accumulation
Option Either and Try Error Handling
Handle errors functionally with Option, Either, and Try: map, flatMap, recover, and for-comprehensions.
Best for: Null-safe programming with Option
Exception Handling Patterns
Handle exceptions in Scala: try-catch-finally, Try monad, NonFatal, and custom exceptions.
Best for: Graceful error recovery