Search code examples
javasentry

Wait until Sentry sent the error report before exiting the application


I'm using Sentry to report errors from my desktop application. An issue I'm running into is that if the exception caused the application to crash, it seems to never reach the Sentry servers. From debugging Sentry itself, it looks like exceptions are placed in a buffer for later sending, but in this particular case, I need them sent synchronously.

How do I do that?

I'm reporting the exceptions like this:

Sentry.capture(e);

Solution

  • Sentry exposes a method close which internally calls the closeConnection.

    Looking at the BufferedConnection, the code will wait for sometime to let the buffer clear.

    In short: try calling: Sentry.close();