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

Add Application.prototype.handleError #53

Merged
merged 2 commits into from Jan 10, 2018
Merged

Add Application.prototype.handleError #53

merged 2 commits into from Jan 10, 2018

Conversation

@javan
Copy link
Contributor

@javan javan commented Jan 10, 2018

Supply your own error handler function to override the default console.error. Useful for sending errors to a tracking service like Sentry.

const application = Application.start()

application.handleError = (error, message, detail) => {
  console.warn(message, detail)
  Raven.captureException(error)
}
Supply your own error handler function to override the default `console.error`.
@sstephenson sstephenson changed the base branch from master to 1-0 Jan 10, 2018
@sstephenson sstephenson added this to the 1.0 milestone Jan 10, 2018
@sstephenson sstephenson changed the title Add Application#setErrorHandler Add Application.prototype.handleError Jan 10, 2018
@sstephenson sstephenson merged commit 9690ffa into 1-0 Jan 10, 2018
1 check passed
1 check passed
ci/circleci Your tests passed on CircleCI!
Details
@sstephenson sstephenson deleted the error-handler branch Jan 10, 2018
@rwojsznis
Copy link

@rwojsznis rwojsznis commented Mar 26, 2019

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 throw is not the default here? (so if you have sentry it will be reported properly via window.onerror by default)

And ofc thanks for this PR @javan ! ❤️

@sstephenson
Copy link
Contributor

@sstephenson sstephenson commented Mar 28, 2019

@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
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants