@nick-bull/create-error
v0.4.0
Published
Creates a decorated error
Downloads
34
Readme
A utility for creating errors
Installation
npm i @nick-bull/create-error
Usage
const options = {
type: 'error:badThing',
message: (payload) => `An error message for ${payload.user}!`,
messageContext: {user: 'you'},
};
const message = 'An error message';
try {
throw Error('Undefined definition definitely directly demonstrably due to 0x234235');
}
catch (error) {
const createdError = createError(options, error);
console.log(createdError.trace);
}