I don't know if I am doing something incorrect here or what, but I have a question regarding error handling in angular.
I've gone through several similar questions on the website but they don't answer my question or solve my problem.
So this is basically what I'm trying to do:
var deferObject = $q.defer();
$http(some_url + user_entered_value).then(function(response){
deferObject.resolve(response.data);
}, function(error){
//error handling code here
deferObject.reject(error.data);
});
The server returns an error object which looks like this: {"status":"500","error":"Internal Server Error"}
Whenever there is an error in the application, angular throws an error by logging it in the console: "failed to load resource: Internal server error".
So here are my questions:
How do I prevent the angular error logging?
How do I handle that error?
I tried doing this:
var deferObject = $q.defer();
$http(some_url + user_entered_value).then(function(response){
deferObject.resolve(response.data);
}, function(error){
//error handling code here
deferObject.reject(error.data);
}).catch(function(e){
throw e;//to handle the error
});
But I still get the error in the console.