Error Handling,
Reimagined.

A TypeScript library that brings Python-inspired error handling to JavaScript. Exception chaining, hierarchical inheritance, and rich error semantics through a function-based API.

example.ts
import { error, raise, is, causes } from '@deessejs/errors';

const ValidationError = error({
  name: 'ValidationError',
  message: 'Field "{field}" is invalid: {reason}',
});

const err = ValidationError({
  field: 'email',
  reason: 'invalid format',
});

// Chain errors with .from()
appErr.from(err);

// Type-safe checking
if (is(err, ValidationError)) {
  console.log(err.fields.field); // "email"
}

From fragile to robust.

Stop relying on fragile string matching. Get type-safe, structured errors that make debugging a breeze.

before.ts
// Traditional approach
throw new Error('Validation failed');

catch (err) {
  if (err.message.includes('Validation')) {
    // String matching... fragile!
  }
}
after.ts
// @deessejs/errors approach
raise(ValidationError({ field: 'email' }));

catch (err) {
  if (is(err, ValidationError)) {
    // Type-safe, reliable
    console.log(err.fields.field);
  }
}

Ready to get started?

Install the package and start building better errors today.

Read the docs