mgonto / restangular

AngularJS service to handle Rest API Restful Resources properly and easily
MIT License
7.87k stars 840 forks source link

using seterrorinterceptor only with specific routes or errors #444

Closed alonisser closed 10 years ago

alonisser commented 10 years ago

can I set a specific errorinterceptor only to a specific route? and/or error? (seperating between 401,404,500 etc) I realize that this can be done in in big function that would parse the returned error and decide what do to according to specifc logic, but more granulation would be nicer

Also what does seterrorinterceptor return? do I get the error code?

BTW: restangular rocks! I'm in the process of moving all of our angular-server talking code to use it. Thanks for this

mgonto commented 10 years ago

Hey,

So for now, no there's no way of setting granular error codes. I'll leave this open to be able to do that (Implement that as an enhancement).

Error interceptor now receives as a parameter the response, where you can get the status via response.status. Here's more documentation on it and on what it returns: https://github.com/mgonto/restangular#seterrorinterceptor

HOpe it helps!

mgonto commented 10 years ago

Hey,

For now I'm not going to implement this, but you can easily do this and use it as a Plugin :)