Errors your compiler understands

Define your errors. Throw them like normal. The tooling catches what you miss.

npm install faultline

Pick your starting point

Both paths use the same error definitions. Start simple and level up, or jump straight into the full system.

Start here

Throw & catch

Keep your existing patterns. Define typed errors, throw them, and let the ESLint plugin catch your mistakes.

throw UserErrors.NotFound({ userId: id }); // catch — fully typed if (isErrorTag(e, UserErrors.NotFound)) { e.data.userId // string e.status // 404 }
  • ESLint warns on throw new Error()
  • ESLint flags incomplete catch blocks
  • Structured .toJSON() serialization
  • Zero paradigm shift
Get started
Full power

Result types & beyond

Compiler-tracked errors through your entire pipeline. Exhaustive matching, error boundaries, and typed recovery.

getUser(userId) .andThen(user => chargeCard(user, amount)) .match({ ok: (receipt) => ({ status: 200 }), 'User.NotFound': (e) => ({ status: 404 }), 'Payment.Declined': () => ({ status: 402 }), });
  • Same defineErrors — nothing to rewrite
  • Compiler tracks every error in the chain
  • Exhaustive matching and catchTag recovery
  • Cross-layer boundary mappings
Explore Result types

The ESLint plugin is the secret weapon

No other error library has this. The linter knows what your functions throw and tells you what you missed.

You write a raw throw faultline/no-raw-throw

Flags throw new Error(...) and nudges you toward a typed factory. You fix it in one line.

Your catch block is incomplete faultline/uncovered-catch

Analyzes what each function can throw — even across files — and warns when your catch doesn't cover all cases.

Someone adds a new error type faultline/uncovered-catch

Immediately flags every catch block in your codebase that needs updating. You'll never silently miss a new error type.

Try it live

A pre-configured TypeScript project with faultline installed. Edit the code, run it, experiment with the API.

Open in StackBlitz View examples on GitHub

Ready to start?

npm install faultline