You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
I want to create an error with custom constructor so I can set custom properties like this:
I also want to wrap this error like this:
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?
The text was updated successfully, but these errors were encountered: