Okan Yıldırım
05/17/2022, 5:32 PMinstall(StatusPages) {
exception<AuthenticationException> { call, cause ->
call.respond(
HttpStatusCode.Unauthorized,
message = cause.message ?: "Unauthorized message"
)
}
exception<AuthorizationException> { call, cause ->
call.respond(HttpStatusCode.Forbidden, message = cause.message ?: "Unauthorized message")
}
status(HttpStatusCode.NotFound) { call, _ ->
call.respond(
mapOf("message" to "404: Page Not Found")
)
}
exception<Throwable> { call, cause ->
call.respondText(text = "500: $cause", status = HttpStatusCode.InternalServerError)
}
}