JSPM

  • Created
  • Published
  • Downloads 2866
  • Score
    100M100P100Q109422F
  • License MIT

Custom error object.

Package Exports

  • err-object

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (err-object) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Build Status Coverage

err-object

Custom error object.

Tired writing code like this:

const error = new SomeError('message')
error.code = 'SOME_ERROR'

There are tremendous modules about custom errors in the NPM, but NONE of those could be usable.

Install

$ npm install err-object

Usage

import err from 'err-object'
const message = 'message'

err(message)
// Error
// - message

err({
  message,
  name: 'ImplementError',
  code: 'ERR_IMPL'
})
// Error
// - message
// - name: 'ImplementError'
// - code: 'ERR_IMPL'

err(message, TypeError)
// TypeError
// - message

License

MIT