clean-typescript-error-handling
Installation
SKILL.md
Clean Error Handling
Error handling is part of the public behavior. Keep normal flow readable, preserve context, and make recoverable failures explicit.
EH1: Throw Useful Errors
Throw Error objects or project-specific subclasses. Do not throw strings or untyped objects.
// Bad
throw "User not found";
// Good
throw new Error(`User not found: ${userId}`);
EH2: Catch Unknown
Treat caught values as unknown and narrow before reading properties.