diff --git a/feign-reactor-webclient/src/main/java/reactivefeign/webclient/WebReactiveFeign.java b/feign-reactor-webclient/src/main/java/reactivefeign/webclient/WebReactiveFeign.java index 8c57e99e..9f2cf795 100644 --- a/feign-reactor-webclient/src/main/java/reactivefeign/webclient/WebReactiveFeign.java +++ b/feign-reactor-webclient/src/main/java/reactivefeign/webclient/WebReactiveFeign.java @@ -22,6 +22,7 @@ import reactivefeign.client.ReadTimeoutException; import reactor.netty.http.client.HttpClient; +import java.util.Objects; import java.util.function.BiFunction; import static reactivefeign.webclient.NettyClientHttpConnectorBuilder.buildNettyClientHttpConnector; @@ -78,13 +79,13 @@ protected ClientHttpConnector clientConnector() { @Override public BiFunction errorMapper(){ - return (request, throwable) -> { - if(throwable instanceof WebClientRequestException - && throwable.getCause() instanceof io.netty.handler.timeout.ReadTimeoutException){ + return Objects.requireNonNullElseGet(this.errorMapper, () -> (request, throwable) -> { + if (throwable instanceof WebClientRequestException + && throwable.getCause() instanceof io.netty.handler.timeout.ReadTimeoutException) { return new ReadTimeoutException(throwable, request); } return null; - }; + }); } }