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

Handle Promise rejection in guards #2833

Open
posva opened this issue Jun 27, 2019 · 5 comments
Open

Handle Promise rejection in guards #2833

posva opened this issue Jun 27, 2019 · 5 comments
Labels
feature request fixed on 4.x This issue has been already fixed on the v4 but exists in v3 has workaround

Comments

@posva
Copy link
Member

posva commented Jun 27, 2019

Version

3.0.3

Reproduction link

https://jsfiddle.net/orzwg537/

Steps to reproduce

Run the fiddle and look in console

What is expected?

a message saying error caught

What is actually happening?

There is an Unhandled Promise rejection instead


Currently, errors thrown in guards are caught by router.onError but Promises rejections (or error thrown in an async function) are not caught. This should be handled in all the other guards as well. To handle them right now it is possible by passing the error to next:

try {
  await fetchdata()
} catch (error) {
  next(error)
}
@berniegp

This comment has been minimized.

@posva

This comment has been minimized.

@fairking

This comment has been minimized.

@posva

This comment has been minimized.

@fairking
Copy link

fairking commented Oct 10, 2019

@denis-pujdak-adm-it yeah, it's not related. There is more information about the Uncaught Promise you are experiencing on the comment above. This feature request is to handle explicit rejections in the guard

Ok. Thanks. I assume this is the solution: @berniegp Using a router-link instead of the initial $router.push() call removes the error..

@posva posva added the fixed on 4.x This issue has been already fixed on the v4 but exists in v3 label Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request fixed on 4.x This issue has been already fixed on the v4 but exists in v3 has workaround
Projects
None yet
Development

No branches or pull requests

3 participants