create-error
create-error copied to clipboard
A simple utility for creating sub-classed errors in Javascript
@tgriesser, maybe you can find my [node-error](https://github.com/adriano-di-giovanni/node-error) useful ;) I developed it to handle/log custom errors using Bookshelf and decided to share it
Specifically wanted to use the return of `querystring`.parse() to save the response of an api call to a prop on my custom error. Took awhile to figure out that qs.parse()...
Here's a testcase: ```js var createError = require('create-error'); var MyCustomError = createError('MyCustomError', {prop1: 1}); var SubCustomError = createError(MyCustomError, 'CoolSubError', {prop2: 2}); var sub = new SubCustomError('My Message', {prop3: 3}); console.log(sub.prop1);...
create-error has a pretty naive cloning implementation that seems to prevent you from storing any real objects on the error. For example: ``` javascript var MyCustomError = createError('MyCustomError'); new MyCustomError('Bad!',...