I saw a very special (and weird) error handling code, which goes like this:
function SomeError(name, message) {
this.name = name;
this.message = message;
this.stack = (new Error()).stack;
}
SomeError.prototype = Object.create(Error.prototype);
On promise catch:
promise.catch(e => {
throw new SomeError('someName', e.message);
});
My question:
Is there any reasonable cause to make it this way?
I thought of handling this like:
promise.catch(e => {
e.name = 'my error name';
throw new Error(e);
});