Learn robust error-handling patterns across TypeScript, Python, and Go applications.
Copy the install command and let the AI configure it · recommended for beginners
Please install the "error-handling" skill from askskill: 1. Download https://raw.githubusercontent.com/affaan-m/ECC/main/skills/error-handling/SKILL.md 2. Save it as ~/.claude/skills/error-handling/SKILL.md 3. Reload skills and tell me it's ready
Design a unified error-handling standard for TypeScript, Python, and Go projects. Cover error taxonomy, typed errors, custom exceptions, logging fields, user-facing error messages, and which errors should be retried, degraded gracefully, or fail fast.
A practical cross-language error-handling standard with categories, code patterns, and user messaging guidance.
I have a service that calls a third-party payment API. Give me an error-handling approach in TypeScript or Go covering timeouts, retry backoff, circuit breakers, idempotency, monitoring alerts, and how to avoid exposing low-level errors directly to users.
A production-ready API resilience plan showing how to handle dependency failures while protecting user experience.
Help me design error boundaries and user messaging for a frontend app. Distinguish network errors, permission errors, form validation errors, and system exceptions, and include developer logging details plus actionable next steps for users.
A frontend error-boundary and messaging plan balancing observability with clear user guidance.
Consistent, robust error handling patterns for production applications.
catch block must either handle, re-throw, or log// Define an error hierarchy for your domain
export class AppError extends Error {
constructor(
message: string,
public readonly code: string,
public readonly statusCode: number = 500,
public readonly details?: unknown,
) {
super(message)
this.name = this.constructor.name
// Maintain correct prototype chain in transpiled ES5 JavaScript.
// Required for `instanceof` checks (e.g., `error instanceof NotFoundError`)
// to work correctly when extending the built-in Error class.
Object.setPrototypeOf(this, new.target.prototype)
}
}
export class NotFoundError extends AppError {
constructor(resource: string, id: string) {
super(`${resource} not found: ${id}`, 'NOT_FOUND', 404)
}
}
export class ValidationError extends AppError {
constructor(message: string, details: { field: string; message: string }[]) {
super(message, 'VALIDATION_ERROR', 422, details)
}
}
export class UnauthorizedError extends AppError {
constructor(reason = 'Authentication required') {
super(reason, 'UNAUTHORIZED', 401)
}
}
export class RateLimitError extends AppError {
constructor(public readonly retryAfterMs: number) {
super('Rate limit exceeded', 'RATE_LIMITED', 429)
}
}
For operations where failure is expected and common (parsing, external calls):
type Result<T, E = AppError> =
| { ok: true; value: T }
| { ok: false; error: E }
function ok<T>(value: T): Result<T> {
return { ok: true, value }
}
function err<E>(error: E): Result<never, E> {
return { ok: false, error }
}
// Usage
async function fetchUser(id: string): Promise<Result<User>> {
try {
const user = await db.users.findUnique({ where: { id } })
if (!user) return err(new NotFoundError('User', id))
return ok(user)
} catch (e) {
return err(new AppError('Database error', 'DB_ERROR'))
}
}
const result = await fetchUser('abc-123')
if (!result.ok) {
// TypeScript knows result.error here
logger.error('Failed to fetch user', { error: result.error })
return
}
// TypeScript knows result.value here
console.log(result.value.email)
import { NextRequest, NextResponse } from 'next/server'
function handleApiError(error: unknown): NextResponse {
// Known application error
if (error instanceof AppError) {
return NextResponse.json(
{
error: {
code: error.code,
message: error.message,
...(error.details ? { details: error.details } : {}),
},
},
{ status: error.statusCode },
)
}
// Zod validation error
if (error instanceof z.ZodError) {
return NextResponse.json(
{
error: {
code: 'VALIDATION_ERROR',
message: 'Request validation failed',
details: error.issues.map(i => ({
field: i.path.join('.'),
message: i.message,
})),
},
},
…
Handle returns, refunds, fraud checks, and warranty claim decisions efficiently.
Use Bun for runtime, bundling, testing, packages, and Node migration decisions.
Use the correct Ethereum Keccak-256 hashing in Node.js and TypeScript.
Apply Nuxt 4 patterns for SSR safety, performance, and data fetching.
Generate images, videos, and audio with one unified AI media workflow.
Design Quarkus 3 backend patterns for messaging, APIs, data, and async workflows.
Learn idiomatic Go patterns and best practices for robust, maintainable applications.
Investigate VS Code telemetry errors and pinpoint root causes effectively.
Learn idiomatic Rust patterns, ownership, concurrency, and robust error handling practices.
Extract and verify React error messages and codes to debug unknown warnings.
Fix lint, formatting, and common code issues before passing CI.
Build HTTP service patterns with lifecycle hooks, WebSockets, SSE, and proxying.