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

Vue.config.errorHandler dosn't handle the error thrown by beforeRouteUpdate method #10826

Closed
foyzhao opened this issue Nov 15, 2019 · 3 comments

Comments

@foyzhao
Copy link

foyzhao commented Nov 15, 2019

What problem does this feature solve?

I'm using a global error handler for process errors during component render function and watchers.

But it does not catch the exception thrown in the list method below:

export default {
  async created() {
    await this.list();
  },
  async beforeRouteUpdate(to, from, next) {
    next();
    await this.list();
  },
  methods: {
    async list() {
      return axios.get('An invalid url');
    },
  },
};

What does the proposed API look like?

No need to change API

@posva
Copy link
Member

posva commented Nov 15, 2019

That is normal, they are different kind of errors so Vue Router doesn't relay them to Vue by default. Regarding async errors: vuejs/vue-router#2833

@posva posva closed this as completed Nov 15, 2019
@foyzhao
Copy link
Author

foyzhao commented Nov 16, 2019

If I want to refresh the page data when the route is updated, the error in created and the error in beforeRouteUpdate are the same type.

@foyzhao
Copy link
Author

foyzhao commented Nov 16, 2019

And if I want to catch all these exceptions in Vue.config.errorHandler, what is your 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