Ray Eldath
01/26/2020, 7:22 PMApiException
thrown in handler, and then wraps then into a val error = Body.auto<ApiException>().toLens()
, so i can avoid use return@run Response(...).with(...)
in every place rejecting a malformed request with a json body which constituted of reason and custom diagnose info. so i write this, as learn from `CatchLensFailure`:
private val filterChain by lazy {
Filter.NoOp.then(Filter { next ->
{
try {
next(it)
} catch (e: ApiException) {
Response(Status.BAD_REQUEST).with(error of e)
}
}
})
}
but seems that whenever the of
operator meets something Exception
, it not works. instead of construct the content, it'll print the stacktrace.
i debug and examine the stacktrace but still cant find where is this behavior defined... is there any workaround...?