Reputation: 1263
I am using Sentry to log my Java exceptions in an application I am building.
Sentry is awesome for Production issues but when I'm just messing about in development I want to be able to still get the stack trace out to the console.
However, once Sentry.init(...)
has been run exceptions seem to be suppressed and only available on the Sentry website.
What is the option that I should set in Sentry.init(...)
to continue having console stack traces for development?
Upvotes: 0
Views: 826
Reputation: 56
I found two ways to deal with that. Both can be configured in Sentry.init
. I hope it is fine if share my Kotlin
snippets, it shouldn't be very different in Java
.
If it is okay for you to not send the uncaught exceptions to Sentry you can disable the UncaughtExceptionHandler
:
if (environment == "DEVELOPMENT") {
options.enableUncaughtExceptionHandler = false
}
Otherwise, if you still want to have that exceptions in Sentry, you could use setBeforeSend
to print it to the console first:
options.setBeforeSend { event, hint ->
if (environment == "LOCAL") {
System.err.println(event.throwable?.printStackTrace())
}
return@setBeforeSend event
}
Upvotes: 1