spring-framework / org.springframework.web.reactive.function.server / CoRouterFunctionDsl / onError

onError

fun onError(predicate: (Throwable) -> Boolean, responseProvider: suspend (Throwable, ServerRequest) -> ServerResponse): Unit

Filters all exceptions that match the predicate by applying the given response provider function.

Parameters

predicate - the type of exception to filter

responseProvider - a function that creates a response

Since
5.2

inline fun <reified E : Throwable> onError(noinline responseProvider: suspend (Throwable, ServerRequest) -> ServerResponse): Unit

Filters all exceptions that match the predicate by applying the given response provider function.

Parameters

E - the type of exception to filter

responseProvider - a function that creates a response

Since
5.2