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

Errors thrown in instance methods do not trigger errorCaptured or errorHandler #8568

Closed
michaelfelixmurphy opened this issue Jul 27, 2018 · 3 comments

Comments

@michaelfelixmurphy
Copy link

Version

2.5.16

Reproduction link

https://codesandbox.io/s/kw0qy3r8wo

Steps to reproduce

Click the watcher button. An error is thrown and caught by both App.vue and the global handler.
Click the method button. An error is thrown but not caught by anything.

What is expected?

The error handler of parents (and the global handler if propagated) should be called for all errors thrown in a child component. I would expect that this would happen no matter where the error is thrown. Of course async/promise code is a reasonable exception as I understand that to be a language limitation.

What is actually happening?

The error is not caught by any handler.


This is similar to #8567. Is there any documentation on exactly which parts of components you can throw errors in and expect them to be caught by the parent(s)?

@afontcu
Copy link
Member

afontcu commented Jul 30, 2018

Hi! As stated by Evan You here #6953 (comment), errorHandler only capture errors in the following:

  • render functions
  • watcher callbacks
  • lifecycle hooks
  • component event handlers

Evan said that "DOM event handlers are currently not included and probably should.", so they might be working on it :)

(btw, in your CodeSandbox the button is calling a non-existent doMethod()! You named the method onclick() down in the methods object 😇)

@michaelfelixmurphy
Copy link
Author

Thanks for the quick response. That does answer my question. I hadn't seen that issue.

I would strongly request that that list be added to the documentation. Without it, it's very unreliable to use the error handling functions. The nature of error handling is one has to know what will be coved and what won't.

Since my question is answered you can close this issue. Or leave it open as a request for the docs to be updated and a request to add error handling to DOM events. (I'm not sure what your process is for this.)

(Whoops, thanks for pointing out the typo. Fixed in the CodeSandbox, for what it's worth.)

@posva
Copy link
Member

posva commented Jul 31, 2018

Closing in favour of #8567
It's mentioned in the documentation: https://vuejs.org/v2/api/#errorHandler
If you have any ideas about how to improve it, PR are welcome! 😄

@posva posva closed this as completed Jul 31, 2018
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

3 participants