/pretty-error-classes.js

Dynamically create error classes with a sugary syntax.

Primary LanguageJavaScriptThe UnlicenseUnlicense

Pretty Error Classes

Build Status

Allows you to dynamically create error classes, with an elegant API.

const { ValidationError } = require('pretty-error-classes')

try {
  throw new ValidationError('meow')
} catch (e) {
  if (e instanceof ValidationError) {
    console.log('validation error') // gets here
  } else {
    console.log('generic catching') // does not get here
  }
}