Skip to content

Instantly share code, notes, and snippets.

@aqua30
Created September 5, 2022 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aqua30/e903b2789626f2cfbed115277afda6ff to your computer and use it in GitHub Desktop.
Save aqua30/e903b2789626f2cfbed115277afda6ff to your computer and use it in GitHub Desktop.
install(StatusPages) {
exception<Throwable> { call, throwable ->
when(throwable) {
is ValidationException -> {
call.respond(
HttpStatusCode.BadRequest,
ExceptionResponse("${throwable.message}", HttpStatusCode.BadRequest.value)
)
}
is ParsingException -> {
call.respond(
HttpStatusCode.NotFound,
ExceptionResponse("${throwable.message}",HttpStatusCode.ExpectationFailed.value)
)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment