Just found a solution to my problem and thought it would be a good idea to share it. Few days ago we changed our structure and we are now using factories to call our API and return promises.
Unfortunately, we realized that since we made this change our error
callbacks were not executed anymore.
I first thought the problem was linked somehow to the server return as we changed the way we handle exceptions. But it was not.
The real weird thing was that we were always going into the success
callback and never into the error
one even with an error 500 or 404 or whatever…
So I googled it (quite a lot) and then found this brilliant stackoverflow answer which gives the right answer (for me) on the second answer.
Here was my problem. I was intercepting the errors like this:
But as it says on SO answer it should have been:
Indeed in case your promise gets rejected, you need to return it otherwise Angular thinks that everything is fine and go through the success
callback!
Hope this helps!