I would like to create my own custom error, something like this:
function CustomError(message) {
Error.captureStackTrace(this);
this.message = message;
this.name = "SomeCustomError";
}
CustomError.prototype = Object.create(Error.prototype);
How should I integrate custom errors in angular? I would simply be able to throw the same custom error anywhere I am in angular, no matter if in a service, controller, or similar. I certainly wouldn't want to 'dependency inject' the CustomError each time.
throw CustomError('some message');
Or, if I am thinking about, I also could simply:
throw {name : "CustomError", message : "some message"};
Any thoughts?