bayleedev / pretty-error-classes.js

Dynamically create error classes with a sugary syntax.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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
  }
}

About

Dynamically create error classes with a sugary syntax.

License:The Unlicense


Languages

Language:JavaScript 100.0%