https://kotlinlang.org logo
#ktor
Title
# ktor
s

spierce7

01/15/2022, 1:46 AM
If I want to catch all my exceptions and log them to bugsnag, or Datadog, where is the best place to do that? I was considering the
StatusPages
plugin, using the
Throwable
catch all.
Copy code
install(StatusPages) {
            exception<Throwable> {
                call.respond(HttpStatusCode.InternalServerError)
            }
        }
r

Rescribet

01/15/2022, 3:35 PM
We used this as well, but it doesn’t catch exceptions in plugins (the classical API at least, don’t know what happens with the new
createApplicationPlugin
API)
r

Rustam Siniukov

01/17/2022, 1:18 PM
@Rescribet Can you create tickets for such plugins? It’s not an expected behaviour
r

Rescribet

01/17/2022, 4:49 PM
@Rustam Siniukov Yes, I’ll see if I can make a repro first
🙏 1
s

spierce7

01/17/2022, 9:30 PM
@Rustam Siniukov So the approach I’m taking should be fine then?
r

Rustam Siniukov

01/17/2022, 10:21 PM
Yes, it should work. Otherwise, please file a bug
r

Rescribet

01/18/2022, 2:00 PM
@Rustam Siniukov The 2.0.0-beta-1 StatusPages does catch plugin exceptions, but doesn’t prevent later handlers from being called. Which can lead to unexpected behaviour. We currently do a manual check to see StatusPages was activated to work around this:
Copy code
if (call.attributes.contains(AttributeKey<Unit>("StatusPagesTriggered"))) {
  return@get
}
https://youtrack.jetbrains.com/issue/KTOR-3707
a

Aleksei Tirman [JB]

01/19/2022, 7:45 AM
@Rescribet thank you. I confirm that it's a bug.
🐛 1
2 Views