Open
Description
We use Sentry in both of our wallet clients to capture exceptions, but we don't have an easy way to submit Sentry reports from libraries (in particular from controllers). We can throw an error, but if we want to capture an error with Sentry without interrupting the operation, there is no great solution.
We can use setTimeout
to throw the error uncaught in the next tick of the event loop. This works, this is what we've done before, but it's not ideal for a few reasons:
- The error gets logged as "uncaught", which suggests it wasn't anticipated.
- We have no control over how it's logged to the console - we have to throw it in order for Sentry to capture it.
- The error report is delayed by an unpredictable amount of time, making it ambiguous when the real error occurred relative to other events we might see in breadcrumbs
We should create an "error reporting service" that accepts a captureException
function, and allows submitting error events via messenger action. This would provide a simple way for any library to report an exception without the downsides listed above.