you could do this ``` fun <T : Exception...
# ktor
k
you could do this
Copy code
fun <T : Exception> handler(code: HttpStatusCode): suspend PipelineContext<Unit>.(T) -> Unit = {
            cause ->
            log.error(cause.localizedMessage)
            val sw = StringWriter()
            cause.printStackTrace(PrintWriter(sw))
            val exceptionAsString = sw.toString()
            log.error(exceptionAsString)
            call.response.status(code)
            call.respond(cause.message.toString())
        }
        exception<NoSuchElementException>(handler(HttpStatusCode.NotFound))
        exception<InvalidJwtException>(handler(HttpStatusCode.Unauthorized))