A general base Error class that can be extended to create custom Error classes
npm install @ianwalter/base-error --save
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)
*/
Hippocratic License - See LICENSE
Created by Ian Walter