-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
I want to create an error with custom constructor so I can set custom properties like this:
var HTTPError = createCustomError('HTTPError', null, function(code) {
this.code = code;
});
var error = new HTTPError("You don't have permission', 403);
console.log(error.code);
I also want to wrap this error like this:
var error = new ValidationError("Missing field");
var serverError = new HTTPError("Something went wrong", error);
I can't do both at the same time, either I have to use a custom constructor, or another error object.
How can I create a custom error that wraps an error object, and I can set custom properties on it?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels