@ianwalter/base-error

A general base Error class that can be extended to create custom Error classes

Stats

StarsIssuesVersionUpdatedCreatedSize
@ianwalter/base-error
6.1.02 years ago4 years agoMinified + gzip package size for @ianwalter/base-error in KB

Readme

@ianwalter/base-error

A general base Error class that can be extended to create custom Error classes

npm page CI

Installation

npm install @ianwalter/base-error --save

Usage

import BaseError from '@ianwalter/base-error'

// Extend BaseError to create your custom error and optionally pass additional
// data to be included in the error message.
class SomeError extends BaseError {
  constructor (details) {
    super('Something happened', details)
  }
}

// Implementation example:
const someError = new SomeError({ user: 1 })
if (someError instanceof SomeError) {
  console.error(someError)
}
/*
Logs an error like:

SomeError: Something happened
{
  "user": 1
}
(stacktrace)
*/

License

Hippocratic License - See LICENSE

 

Created by Ian Walter

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.