diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java index 7e8219c167..9097000ccc 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java @@ -530,7 +530,7 @@ public interface WebClient { * return response.bodyToMono(ErrorContainer.class); * } * else { - * return Mono.error(response.createException()); + * return response.createException(); * } * }); * @@ -562,7 +562,7 @@ public interface WebClient { * return response.bodyToMono(ErrorContainer.class).flux(); * } * else { - * return Flux.error(response.createException()); + * return response.createException().flux(); * } * }); * diff --git a/src/docs/asciidoc/web/webflux-webclient.adoc b/src/docs/asciidoc/web/webflux-webclient.adoc index 3099ecb02d..3c2d18c561 100644 --- a/src/docs/asciidoc/web/webflux-webclient.adoc +++ b/src/docs/asciidoc/web/webflux-webclient.adoc @@ -559,7 +559,7 @@ depending on the response status: } else { // Turn to error - return response.createException().flatMap(Mono::error); + return response.createException(); } }); ----