Add Application.prototype.handleError #53
Merged
Conversation
Supply your own error handler function to override the default `console.error`.
Welp, that caught me by surprise (obviously in production I would never-ever except such library to swallow errors for me - maybe I ask why And ofc thanks for this PR @javan ! |
@emq Could you open a new issue so your comment doesn’t get lost in the stream? Thank you! |
ghiculescu
added a commit
to ghiculescu/stimulus
that referenced
this pull request
Jan 8, 2021
Proposing some changes that I mentioned [here](hotwired#236 (comment)). To recap, I think the error logging in Stimulus is great, but several people (me included) have been caught by the fact that errors aren't reported elsewhere out of the box. The aim of this PR is to automatically integrate with third party error tracking services where possible, and to improve the documentation where not. Specific changes: - If `window.onerror` is defined, Stimulus will now call it after logging an error. Many error tracking tools define this method, eg. [Sentry](https://github.com/getsentry/sentry-javascript/blob/0ee07995d415d3870608c477cbdcf8445a51e1bb/packages/browser/src/loader.js#L192), [Airbrake](https://github.com/airbrake/airbrake-js/blob/9d4787b1c559aa39107d7288f46c4108c9a9d954/packages/browser/src/notifier.ts#L70) - Added documentation on how error handling works, including what happens out of the box and how to override it (with code sample from hotwired#53) - Added tests for the error handler.
ghiculescu
added a commit
to ghiculescu/stimulus
that referenced
this pull request
Jan 8, 2021
Proposing some changes that I mentioned [here](hotwired#236 (comment)). To recap, I think the error logging in Stimulus is great, but several people (me included) have been caught by the fact that errors aren't reported elsewhere out of the box. The aim of this PR is to automatically integrate with third party error tracking services where possible, and to improve the documentation where not. Specific changes: - If `window.onerror` is defined, Stimulus will now call it after logging an error. Many error tracking tools define this method, eg. [Sentry](https://github.com/getsentry/sentry-javascript/blob/0ee07995d415d3870608c477cbdcf8445a51e1bb/packages/browser/src/loader.js#L192), [Airbrake](https://github.com/airbrake/airbrake-js/blob/9d4787b1c559aa39107d7288f46c4108c9a9d954/packages/browser/src/notifier.ts#L70) - Added documentation on how error handling works, including what happens out of the box and how to override it (with code sample from hotwired#53) - Added tests for the error handler.
ghiculescu
added a commit
to ghiculescu/stimulus
that referenced
this pull request
Jan 8, 2021
Proposing some changes that I mentioned [here](hotwired#236 (comment)). To recap, I think the error logging in Stimulus is great, but several people (me included) have been caught by the fact that errors aren't reported elsewhere out of the box. The aim of this PR is to automatically integrate with third party error tracking services where possible, and to improve the documentation where not. Specific changes: - If `window.onerror` is defined, Stimulus will now call it after logging an error. Many error tracking tools define this method, eg. [Sentry](https://github.com/getsentry/sentry-javascript/blob/0ee07995d415d3870608c477cbdcf8445a51e1bb/packages/browser/src/loader.js#L192), [Airbrake](https://github.com/airbrake/airbrake-js/blob/9d4787b1c559aa39107d7288f46c4108c9a9d954/packages/browser/src/notifier.ts#L70) - Added documentation on how error handling works, including what happens out of the box and how to override it (with code sample from hotwired#53) - Added tests for the error handler.
ghiculescu
added a commit
to ghiculescu/stimulus
that referenced
this pull request
Jan 8, 2021
Proposing some changes that I mentioned [here](hotwired#236 (comment)). To recap, I think the error logging in Stimulus is great, but several people (me included) have been caught by the fact that errors aren't reported elsewhere out of the box. The aim of this PR is to automatically integrate with third party error tracking services where possible, and to improve the documentation where not. Specific changes: - If `window.onerror` is defined, Stimulus will now call it after logging an error. Many error tracking tools define this method, eg. [Sentry](https://github.com/getsentry/sentry-javascript/blob/0ee07995d415d3870608c477cbdcf8445a51e1bb/packages/browser/src/loader.js#L192), [Airbrake](https://github.com/airbrake/airbrake-js/blob/9d4787b1c559aa39107d7288f46c4108c9a9d954/packages/browser/src/notifier.ts#L70) - Added documentation on how error handling works, including what happens out of the box and how to override it (with code sample from hotwired#53) - Added tests for the error handler.
ghiculescu
added a commit
to ghiculescu/stimulus
that referenced
this pull request
Jan 8, 2021
Proposing some changes that I mentioned [here](hotwired#236 (comment)). To recap, I think the error logging in Stimulus is great, but several people (me included) have been caught by the fact that errors aren't reported elsewhere out of the box. The aim of this PR is to automatically integrate with third party error tracking services where possible, and to improve the documentation where not. Specific changes: - If `window.onerror` is defined, Stimulus will now call it after logging an error. Many error tracking tools define this method, eg. [Sentry](https://github.com/getsentry/sentry-javascript/blob/0ee07995d415d3870608c477cbdcf8445a51e1bb/packages/browser/src/loader.js#L192), [Airbrake](https://github.com/airbrake/airbrake-js/blob/9d4787b1c559aa39107d7288f46c4108c9a9d954/packages/browser/src/notifier.ts#L70) - Added documentation on how error handling works, including what happens out of the box and how to override it (with code sample from hotwired#53) - Added tests for the error handler.
ghiculescu
added a commit
to ghiculescu/stimulus
that referenced
this pull request
Jan 8, 2021
Proposing some changes that I mentioned [here](hotwired#236 (comment)). To recap, I think the error logging in Stimulus is great, but several people (me included) have been caught by the fact that errors aren't reported elsewhere out of the box. The aim of this PR is to automatically integrate with third party error tracking services where possible, and to improve the documentation where not. Specific changes: - If `window.onerror` is defined, Stimulus will now call it after logging an error. Many error tracking tools define this method, eg. [Sentry](https://github.com/getsentry/sentry-javascript/blob/0ee07995d415d3870608c477cbdcf8445a51e1bb/packages/browser/src/loader.js#L192), [Airbrake](https://github.com/airbrake/airbrake-js/blob/9d4787b1c559aa39107d7288f46c4108c9a9d954/packages/browser/src/notifier.ts#L70) - Added documentation on how error handling works, including what happens out of the box and how to override it (with code sample from hotwired#53) - Added tests for the error handler.
ghiculescu
added a commit
to ghiculescu/stimulus
that referenced
this pull request
Jan 8, 2021
Proposing some changes that I mentioned [here](hotwired#236 (comment)). To recap, I think the error logging in Stimulus is great, but several people (me included) have been caught by the fact that errors aren't reported elsewhere out of the box. The aim of this PR is to automatically integrate with third party error tracking services where possible, and to improve the documentation where not. Specific changes: - If `window.onerror` is defined, Stimulus will now call it after logging an error. Many error tracking tools define this method, eg. [Sentry](https://github.com/getsentry/sentry-javascript/blob/0ee07995d415d3870608c477cbdcf8445a51e1bb/packages/browser/src/loader.js#L192), [Airbrake](https://github.com/airbrake/airbrake-js/blob/9d4787b1c559aa39107d7288f46c4108c9a9d954/packages/browser/src/notifier.ts#L70) - Added documentation on how error handling works, including what happens out of the box and how to override it (with code sample from hotwired#53) - Added tests for the error handler.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Supply your own error handler function to override the default
console.error
. Useful for sending errors to a tracking service like Sentry.