Ben Brodie
02/10/2021, 6:09 AMCatchAll
filter, but I it looks like that logs the stacktrace to the response, which is not what I would expect or want. I want a 500 status returned on uncaught exception, but I also want a log with the stacktrace. Sure, I can implement this myself with a filter, but I just feel like I’m missing some important piece of the puzzle. Please advise on how to approach exceptions (there will always be exceptions we don’t anticipate, and I want to make sure that these get logged so that in a production system, I can see the stacktrace).Razvan
02/10/2021, 7:50 AMfredrik.nordin
02/10/2021, 9:28 AMobject ErrorLoggingCatchAll {
operator fun invoke(errorStatus: Status = INTERNAL_SERVER_ERROR): Filter = Filter { next ->
{
try {
next(it)
} catch (e: Exception) {
log.error("Some error text here", e)
Response(errorStatus).body("some error message")
}
}
}
}
Ben Brodie
02/10/2021, 11:11 PM