erikras / react-redux-universal-hot-example

A starter boilerplate for a universal webapp using express, react, redux, webpack, and react-transform
MIT License
12k stars 2.5k forks source link

How to catch all uncaught errors globally #1353

Open Ezekiah opened 7 years ago

Ezekiah commented 7 years ago

I would like to know where I should write window.onerror, to catch all error, I tried to put it in the componentDidMount of helpers/Html.js but it doesn't work. Thanks in advance.

bertho-zero commented 7 years ago

You can use https://sentry.io/

OKNoah commented 7 years ago

@bertho-zero The question is where to put their code.

I did something like this in create.js but I don't know if it's ideal.

if (__CLIENT__) {
  window.onunhandledrejection = (event) => {
    console.log('event', event)
    Raven.captureException(event.reason.message)
  }
}