Created
September 5, 2022 17:45
-
-
Save aqua30/62d11555376494d86416de14d2219cab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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