Skip to content

Instantly share code, notes, and snippets.

@aqua30
Created September 5, 2022 17:45
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/62d11555376494d86416de14d2219cab to your computer and use it in GitHub Desktop.
Save aqua30/62d11555376494d86416de14d2219cab to your computer and use it in GitHub Desktop.
install(StatusPages) {
exception<Throwable> { ... }
status(
// any number of status codes can be mentioned
HttpStatusCode.InternalServerError,
HttpStatusCode.BadGateway,
) { call, statusCode ->
when(statusCode) {
HttpStatusCode.InternalServerError -> {
call.respond(
HttpStatusCode.InternalServerError,
ExceptionResponse("Oops! internal server error at our end", HttpStatusCode.InternalServerError.value)
)
}
HttpStatusCode.BadGateway -> {
call.respond(
HttpStatusCode.BadGateway,
ExceptionResponse("Oops! We got a bad gateway. Fixing it. Hold on!", HttpStatusCode.BadGateway.value)
)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment