1

I'm using angularjs' $http service to query my backend server whether a resource exists or not. My backend responses with a 404 if the resource doesn't exist and with a 200 if it exists. I also implemented the second function passed to the promise in order to handle the case the resource doesn't exist.

Everything works like expected besides the fact that angular seems to log an error to the js console, if the resource doesn't exist: Failed to load resource: the server responded with a status of 404 (Not Found).

In my case this is no error and so I'd like angular to stop logging it as an error... just to keep the error console clean for real errors.

1 Answer 1

0

Angular doesn't throw errors on failed $http requests, you won't find regular Angular call stack in error entry details.

$http requests are $q promises, and uncaught $q promises tend to fail silently, unless the opposite thing is done explicitly:

$http.get('...').catch(() => { throw new Error });

The behaviour is caused by console settings and not by the app. In Chrome, the setting is buried inside dev tools preferences.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.