Skip to content
Back to skills

Error Handling

ASecurity

Implement consistent error handling across the application.

  • 27 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added February 7, 2026
developmenttypescriptreactapifrontendbackend

Works with

  • api

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned February 12, 2026

npx -y skills add vneseyoungster/ChocoVine --skill error-handling --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Error Handling?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Error Handling
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vneseyoungster-error-handling/badge)](https://www.skillsdirectory.com/skills/vneseyoungster-error-handling)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: error-handling
description: Implement consistent error handling across the application.
  Use when adding try-catch blocks, error boundaries, or custom error classes.
---

# Error Handling Skill

## Purpose
Ensure consistent, informative error handling.

## Backend Error Handling
Reference: [patterns/backend-errors.md](patterns/backend-errors.md)

### Custom Error Classes
```typescript
// templates/error-class.ts
export class AppError extends Error {
  constructor(
    public code: string,
    message: string,
    public statusCode: number = 500,
    public details?: unknown
  ) {
    super(message);
    this.name = 'AppError';
  }
}

export class ValidationError extends AppError {
  constructor(message: string, details?: unknown) {
    super('VALIDATION_ERROR', message, 400, details);
  }
}

export class NotFoundError extends AppError {
  constructor(resource: string) {
    super('NOT_FOUND', `${resource} not found`, 404);
  }
}
```

### Error Handler Middleware
```typescript
function errorHandler(err, req, res, next) {
  logger.error(err);

  if (err instanceof AppError) {
    return res.status(err.statusCode).json({
      error: {
        code: err.code,
        message: err.message,
        details: err.details
      }
    });
  }

  return res.status(500).json({
    error: {
      code: 'INTERNAL_ERROR',
      message: 'An unexpected error occurred'
    }
  });
}
```

## Frontend Error Handling
Reference: [patterns/frontend-errors.md](patterns/frontend-errors.md)

### Error Boundaries
```tsx
class ErrorBoundary extends React.Component {
  state = { hasError: false };

  static getDerivedStateFromError() {
    return { hasError: true };
  }

  componentDidCatch(error, info) {
    logError(error, info);
  }

  render() {
    if (this.state.hasError) {
      return <ErrorFallback onReset={() => this.setState({ hasError: false })} />;
    }
    return this.props.children;
  }
}
```

### Async Error Handling
```typescript
async function fetchWithError<T>(url: string): Promise<T> {
  const response = await fetch(url);

  if (!response.ok) {
    const error = await response.json();
    throw new ApiError(error.code, error.message);
  }

  return response.json();
}
```

## Logging Guidelines
| Level | Use For |
|-------|---------|
| error | Exceptions, failures |
| warn | Recoverable issues |
| info | Important events |
| debug | Development info |

Files in this skill

  • SKILL.md2.3 KB
  • patterns/backend-errors.md5.3 KB
  • patterns/frontend-errors.md6.4 KB
  • templates/error-class.ts6.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…