Add handleError during event handling #5709
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently handleError is used to handle errors during lifecycle hooks and component rendering. This handles most errors thrown by the component however event handlers are not handled. So a component like:
Will simple throw an error and the error will never be passed to
handleError
nor is one able to useVue.config.errorHandler
for error reporting. For my specific use case I wanted to make sure that the plugin I use to report errors to Honeybadger would catch and report errors in event handlers, but more generally any error reporting that relies onerrorHandler
will require this.It makes sense to me that, for consistency, Vue would want to handle errors in event handlers the same way as is done lifecycle hooks and rendering. This is consistent with the changes requested and completed in #5198 and #4370.
As this is my first PR, I hope these changes are up to the code standard for the project, but if there is anything else needed just let me know and I'll fix it.
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
While it is unlikely any running apps would have depended on this behaviour. This introduces a change which will result in exceptions thrown by event handlers to be handled by
handleError
and any function assigned toVue.config.errorHandler
. Since errors are not re-thrown byhandleError
any code that was depending on errors in events not being handled could theoretically break. I thought it would be worthwhile to note this.The PR fulfills these requirements:
dev
branch for v2.x (or to a previous version branch), not themaster
branchfix #xxx[,#xxx]
, where "xxx" is the issue number)If adding a new feature, the PR's description includes:
Other information: