error-handler
Skill9 starsChanged 12 months agoMITView on GitHub
Provides battle-tested error handling patterns for TypeScript and Python. Use when implementing error handling, creating try/catch blocks, or handling exceptions.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- agentsdance/agentskillstheir own version, first seen Jan 15, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- agentsdance/agentskills★ 3same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository10 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- api-design-patternsSkill
- code-formatterSkill
- devkit-knowledgeSkill
- documentation-templatesSkill
- frontend-designSkill
- product-discoverySkill
- react-patternsSkill
- tailwind-conventionsSkill
- test-generatorSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 8 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 20
Never Swallow Errors: - Always log, re-throw, or handle explicitly
- Distinctive: line 22
Typed Errors: - Use custom error classes for different failure types
- Distinctive: line 92
Use custom error classes for different error types
- Distinctive: line 97
Always clean up resources (use try/finally or context managers)
- Distinctive: line 98
Add retry logic for transient failures
- Distinctive: line 99
Test error paths (negative tests)
- Distinctive: line 105
Use generic error messages without context
- Distinctive: line 109
Use errors for control flow
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Error Handler Skill
Implements robust error handling patterns that provide meaningful errors, graceful degradation, and proper logging.
Resources
For detailed code examples, see:
references/typescript-patterns.md- TypeScript/JavaScript patterns (Express, React)references/python-patterns.md- Python patterns (FastAPI, Flask)
Core Principles
- Fail Fast, Fail Loudly - Catch errors early, make them visible
- Context is King - Include relevant information in error messages
- Never Swallow Errors - Always log, re-throw, or handle explicitly
- User-Friendly Messages - Show generic messages to users, log details server-side
- Typed Errors - Use custom error classes for different failure types
Quick Patterns
Custom Error Class (TypeScript)
export class AppError extends Error {
constructor(
message: string,
public code: string,
public statusCode: number = 500,
public context?: Record<string, unknown>
) {
super(message);
this.name = this.constructor.name;
}
}
// Specific types
export class ValidationError extends AppError {
constructor(message: string, context?: Record<string, unknown>) {
super(message, 'VALIDATION_ERROR', 400, context);
}
}
export class NotFoundError extends AppError {
constructor(resource: string, id: string) {
super(`${resource} not found`, 'NOT_FOUND', 404, { resource, id });
}
}Custom Exception (Python)
class AppError(Exception):
def __init__(self, message: str, code: str, status_code: int = 500, context: dict | None = None):
super().__init__(message)
self.message = message
self.code = code
self.status_code = status_code
self.context = context or {}
class ValidationError(AppError):
def __init__(self, message: str, context: dict | None = None):
super().__init__(message, "VALIDATION_ERROR", 400, context)Error Handling Pattern
async function fetchData(id: string): Promise<Data> {
if (!id) throw new ValidationError('Invalid ID', { id });
try {
const data = await db.find(id);
if (!data) throw new NotFoundError('Data', id);
return data;
} catch (error) {
if (error instanceof AppError) throw error;
throw new DatabaseError('Fetch failed', { id, originalError: error.message });
}
}Best Practices
DO
- Use custom error classes for different error types
- Include context in errors (but sanitize before sending to client)
- Log errors with structured data (method, path, user ID, etc.)
- Provide user-friendly error messages
- Handle errors at appropriate levels (function, route, global)
- Always clean up resources (use try/finally or context managers)
- Add retry logic for transient failures
- Test error paths (negative tests)
DON'T
- Swallow errors silently (
catch (e) {}) - Leak sensitive information in error messages
- Use generic error messages without context
- Ignore promise rejections
- Re-throw errors without adding context
- Return errors as values when exceptions are better
- Use errors for control flow
Error Response Format
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid input data",
"details": [{ "field": "email", "message": "Invalid format" }]
}
}Remember: Good error handling prevents debugging nightmares and provides a better user experience.
Version
- v1.1.0 (2025-12-05): Split into references (typescript-patterns.md, python-patterns.md)
- v1.0.0 (2025-11-15): Initial version
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
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.

