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

feat(errors): capture errors thrown in redirect callback in onError #3251

Merged
merged 3 commits into from
Jul 3, 2020
Merged

feat(errors): capture errors thrown in redirect callback in onError #3251

merged 3 commits into from
Jul 3, 2020

Conversation

raulcabello
Copy link
Contributor

@raulcabello raulcabello commented Jul 1, 2020

Resolves #3201

This PR allows exceptions to be caught in router.onError.

@raulcabello raulcabello changed the title fix(errors): capture errors thrown in redirect callback in onError feat(errors): capture errors thrown in redirect callback in onError Jul 2, 2020
Copy link
Member

@posva posva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks but doing a try catch around the whole navigation is too much. Shouldn't try catching the router.match be enough?

@raulcabello
Copy link
Contributor Author

Hi @posva ! Yes you are right, try catching router.match should be enough. I just thought it might be a good idea to also catch errors in the confirmTransition.
I will make the changes later, thanks for the feedback :)

// https://github.com/vuejs/vue-router/issues/3201
throw e
}
if (route) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we throw again if we fail, I don't think we need the if

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I just removed it in a new commit

Copy link
Member

@posva posva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@posva posva merged commit 40e4df7 into vuejs:dev Jul 3, 2020
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

Successfully merging this pull request may close these issues.

onError does not capture errors thrown in redirect callback
2 participants