I have a exception.js script with the following service:
app.service('Exception', function() {
this.ArgumentUndefinedException = function (message) {
if (!message) {
message = "One or more of the arguments are undefined!";
}
return {
name: 'ArgumentUndefinedException',
message: message
};
}
});
Now I use this in another service:
app.service('Joins', ['Exception', function(Exception) {
this.LEFTJOIN = function(leftArray, rightArray, joinOnLeft, joinOnRight, columnFromRightArray) {
if (!leftArray) {
throw new Exception.ArgumentUndefinedException("Left Array is not defined for LEFTJOIN!");
} else if (!rightArray) {
throw new Exception.ArgumentUndefinedException("Right Array is not defined for LEFTJOIN!");
} else if (!joinOnLeft) {
throw new Exception.ArgumentUndefinedException("Join On Left is not defined for LEFTJOIN!");
} else {
// code to do the left join.
}
}
}])
Then when I use the Joins service in a controller without defining the required arguments, my custom exceptions are not thrown. I do not see any other error message in the console. It simply doesn't show anything in the table. What am I doing wrong or is there a better way to throw custom exceptions in Angular?