ctrlplusb / react-async-component

Resolve components asynchronously, with support for code splitting and advanced server side rendering use cases.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception logging using Sentry.io

kennethtruong opened this issue · comments

Just wondering what do you recommend if I wanted to log exceptions using Sentry. The async components are catching the exception so I'm wondering is there a way to pass a handler to know when an error occurred. Or maybe are we able to get an option to not catch the exceptions?

Hi @kennethtruong

You could add your own wrappers to your promises that first catch, log, then rethrow the errors.

asyncComponent(() => ({
  resolve: () => Promise.reject('💩')
    .catch((err) => { 
      logToSentry(err)
      throw err
   })
})

That's just an off the hand example, but you create a utility function to do the boilerplate for you.