agentleFS
agentsdanceagentsdance/agentskills/skills/error-handler/SKILL.md

error-handler

Skill3 starsChanged 11 months agoApache-2.0View on GitHub

Implement robust error handling patterns. Use when the user needs to add error handling, improve exception management, or create error recovery strategies.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

Files
SKILL.md

Error Handler

Implement comprehensive error handling strategies across languages.

Error Handling Patterns

Try-Catch-Finally

async function fetchUser(id) {
  try {
    const response = await api.get(`/users/${id}`);
    return response.data;
  } catch (error) {
    if (error.response?.status === 404) {
      throw new UserNotFoundError(id);
    }
    throw new ApiError('Failed to fetch user', error);
  } finally {
    metrics.recordApiCall('fetchUser');
  }
}

Result Types (Rust/Go style)

type Result<T, E> = { ok: true; value: T } | { ok: false; error: E };

function parseJson<T>(json: string): Result<T, Error> {
  try {
    return { ok: true, value: JSON.parse(json) };
  } catch (e) {
    return { ok: false, error: e as Error };
  }
}

Error Boundaries (React)

class ErrorBoundary extends React.Component {
  state = { hasError: false };

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

  render() {
    if (this.state.hasError) {
      return <FallbackUI />;
    }
    return this.props.children;
  }
}

Best Practices

PracticeDescription
Be specificCatch specific exceptions, not generic
Fail fastValidate inputs early
Log contextInclude relevant state in error messages
Graceful degradationProvide fallback behavior
Don't swallowAlways handle or rethrow

Custom Error Classes

class AppError(Exception):
    def __init__(self, message, code=None, details=None):
        super().__init__(message)
        self.code = code
        self.details = details or {}

class ValidationError(AppError):
    def __init__(self, field, message):
        super().__init__(f"Validation failed for {field}: {message}")
        self.field = field

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.