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

Timur Atakishiev

04/08/2022, 6:39 AM
Hello guys, I have a question regarding exception handling in ktor. As some of you know to handle REST exception, we generally use @ControllerAdvice and @ExceptionHandler in Spring MVC but these handler works if the request is handled by the DispatcherServlet. However, security-related exceptions occur before that as it is thrown by Filters. How does the exception handler work in ktor? Is it a single point exception handler
Copy code
try{
   smth
} catch(Throwable t) {
   smth
}
that handles everything or it should be done separately for each case like in the spring security? Thanks
a

Aleksei Tirman [JB]

04/08/2022, 12:56 PM
You can use the StatusPages plugin to catch any exceptions.
t

Timur Atakishiev

04/08/2022, 12:56 PM
okay, thanks