Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gracefully handling failed HTTP requests #62

Closed
gabrielmiller opened this issue May 1, 2014 · 2 comments
Closed

Gracefully handling failed HTTP requests #62

gabrielmiller opened this issue May 1, 2014 · 2 comments

Comments

@gabrielmiller
Copy link

I've noticed that the loading bar hangs around indefinitely when any http error occurs. It looks like the responseError interceptor should handle completing failed requests so that the loading bar will vanish, but it appears the interceptor has an error of its own.

When I have an HTTP error I see the HTTP error in my console, but I also get an additional error as follows:

TypeError: Cannot read property 'method' of undefined
    at isCached (eval at <anonymous> (https://test/js/_libraries/jquery/jquery-1.7.1.js:2:11530), <anonymous>:8:14178)
    at responseError (eval at <anonymous> (https://test/js/_libraries/jquery/jquery-1.7.1.js:2:11530), <anonymous>:8:15198)
    at wrappedErrback (eval at <anonymous> (https://test/js/_libraries/jquery/jquery-1.7.1.js:2:11530), <anonymous>:3:30504)
    at eval (eval at <anonymous> (https://test/js/_libraries/jquery/jquery-1.7.1.js:2:11530), <anonymous>:3:32036)
    at Scope.$eval (eval at <anonymous> (https://test/js/_libraries/jquery/jquery-1.7.1.js:2:11530), <anonymous>:4:6956)
    at Scope.$digest (eval at <anonymous> (https://test/js/_libraries/jquery/jquery-1.7.1.js:2:11530), <anonymous>:4:4994)
    at Scope.$apply (eval at <anonymous> (https://test/js/_libraries/jquery/jquery-1.7.1.js:2:11530), <anonymous>:4:7380)
    at done (eval at <anonymous> (https://test/js/_libraries/jquery/jquery-1.7.1.js:2:11530), <anonymous>:3:6376)
    at completeRequest (eval at <anonymous> (https://test/js/_libraries/jquery/jquery-1.7.1.js:2:11530), <anonymous>:3:10106)
    at XMLHttpRequest.xhr.onreadystatechange (eval at <anonymous> (https://test/js/_libraries/jquery/jquery-1.7.1.js:2:11530), <anonymous>:3:11039) undefined 

When I comment out your code in the responseError interceptor and simply call setComplete() the loading bar vanishes when a responseError occurs, but this is much less graceful when there are multiple requests and only one of them fails.

This is using Angular 1.2.13 and release 0.3.0 of your loading bar.

@chieffancypants
Copy link
Owner

This looks very similar to #50 which in every case turned out to be an bad interceptor before it got to the loading bar.

Can you paste the value of config at the time of the error?

@gabrielmiller
Copy link
Author

There actually isn't a config property on the rejection object.

After further exploration it seem that other HTTP error interceptor in our project was causing issues with the loading bar's interceptor. I just needed to make sure that the config property was passed along to the loader bar HTTP interceptor.

Thanks for the suggestion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants