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 7e8219c1678a..79a7e7615d5b 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 @@ interface RequestHeadersSpec> { * return response.bodyToMono(ErrorContainer.class); * } * else { - * return Mono.error(response.createException()); + * return response.createException().flatMap(Mono::error); * } * }); * @@ -562,7 +562,7 @@ interface RequestHeadersSpec> { * return response.bodyToMono(ErrorContainer.class).flux(); * } * else { - * return Flux.error(response.createException()); + * return response.createException().flatMap(Flux::error); * } * }); *