Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Can't throw error (reject promise) in response interceptor #377

Closed
Astray-git opened this issue Sep 1, 2016 · 8 comments
Closed

Can't throw error (reject promise) in response interceptor #377

Astray-git opened this issue Sep 1, 2016 · 8 comments

Comments

@Astray-git
Copy link

Chrome will throw 'Uncaught (in promise)' if I return reject in response interceptor.`

when function takes 3 args: value, fulfilled, rejected, but is called with only 2, no rejected callback here:
https://github.com/vuejs/vue-resource/blob/b9c195daca50188f9338d0900654e75fb6eed483/src/http/client/index.js#L40-L46

@victorwpbastos
Copy link

I'm having this same problem. When using interceptors is there a way to get away with this Uncaught (in promise) message in console?

@steffans
Copy link
Member

steffans commented Sep 6, 2016

Currently it's not implemented that a interceptor can reject a Promise, what would you expect to happen after you returned a rejected Promise?

@victorwpbastos
Copy link

In fact, I just want to silence the errors in console.

@floorish
Copy link

@victorwpbastos Just catch the failed promise yourself and return the original response.
Something like this:

Vue.http.interceptors.push( (request, next) => {

    // do something with request

    next( response => {

            // will return the original response if the promise fails
            return someRejectedPromise().catch( () => response )

    });

});

@antoniopaisfernandes
Copy link

@steffans It would be great to feed the error to raven-js

Currently using window.onunhandledrejection but it does not have yet browser support. Besides, I also don't like a 'catch all' solution that onunhandledrejection provides.

@Kaijun
Copy link

Kaijun commented Nov 1, 2016

I still have no idea how could i perform Error Handling in interceptors... any hacks?

@tiagomatosweb
Copy link

So do I, I have tried a lot to do a catch all in the interception but no luck at all.
Does anyone have any clue?

Cheers

@jarvelov
Copy link
Contributor

jarvelov commented Jun 7, 2017

I just created a pull request to let Promise rejections bubble up the chain, this makes it possible to catch the error using the standard .catchmethod. Please support the pull request to add this feature and make vue-resource's error handling easier.

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

No branches or pull requests

8 participants