Skip to content

Vue.config.errorHandler does not catch errors thrown in lifecycle hooks #4730

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

Closed
blocka opened this issue Jan 17, 2017 · 7 comments
Closed

Comments

@blocka
Copy link

blocka commented Jan 17, 2017

Vue.js version

2.1.9

Reproduction Link

https://jsfiddle.net/o2azdhbx/

Steps to reproduce

What is Expected?

Expect to see an alert saying "Caught an error"

What is actually happening?

See an uncaught exception in the console

@LinusBorg
Copy link
Member

As stated in the docs, this handle only catches errors during render:

If a runtime error occurs during a component’s render, it will be passed to the global Vue.config.errorHandler config function if it has been set.

Demo:

https://jsfiddle.net/Linusborg/o2azdhbx/1/

But it might be a good enhancement to make this possible for lifecycle hooks as well.

Optinions @vuejs/vue ?

@blocka
Copy link
Author

blocka commented Jan 19, 2017

Why is this not considered an error during render? Did it not happen while rendering the parent component?

@kay999
Copy link

kay999 commented Jan 27, 2017

It's quite annoying, because a non-cought error can stop a SPA working.

For example using a small catch around watcher.run() in flushSchedulerQueue makes live easier if an error happens while evaluating a watcher:

function flushSchedulerQueue () {
    ...
    try {
		watcher.run();
    }
    catch(e) {
		config.errorHandler.call(null, e, watcher.vm);
    }
    ...
}

@yyx990803
Copy link
Member

Implemented in dev, will land in 2.2.

@githoniel
Copy link

still exist in the newest Vue 2.2.4
hope this will land soon~~~

@LinusBorg
Copy link
Member

This did land in 2.2.

If you still experience problems, please open a new issue, with a live reproduction on jsfiddle.

@githoniel
Copy link

githoniel commented Mar 15, 2017

move to #5198

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

No branches or pull requests

6 participants