TritonDataCenter / node-verror

Rich JavaScript errors
MIT License
1.18k stars 61 forks source link

Convert 'cause' into 'options' #1

Closed mcavage closed 12 years ago

mcavage commented 12 years ago

This should be 100% backwards-compatible. This allows the caller to now specify cause as an options object such that you can still pass in an Error cause object as well as the constructor so that stack traces are nice. I.e.,

function MyError(cause) {
   VError.call({
     cause: cause,
     constructorOpt: MyError
   });
}
util.inherits(MyError, VError);

new MyError(new Error('blah blah'));