api

http4k / org.http4k.filter / HandleRemoteRequestFailed

HandleRemoteRequestFailed

fun ServerFilters.HandleRemoteRequestFailed(exceptionToBody: RemoteRequestFailed.() -> String = Throwable::getLocalizedMessage): Filter

Handle exceptions from remote calls and convert them into sensible server-side errors. Optionally pass in a function to format the response body from the exception.

fun ClientFilters.HandleRemoteRequestFailed(responseWasSuccessful: Response.() -> Boolean = { status.successful }, responseToMessage: Response.() -> String = Response::bodyString): <ERROR CLASS>

Convert errors from remote calls into exceptions which can be handled at a higher level. Optionally pass in:

  1. a function to determine which responses are successful - defaults to status 200..299
  2. a function to format the exception message from the response.