From: Kai Moritz Date: Thu, 21 Nov 2019 20:00:42 +0000 (+0100) Subject: WIP: WebClient -- Syntax angeglichen X-Git-Tag: wip-webclient~12 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=70a37345037a4ac678c8047cd8cb54727635e5f5;p=facebook-errors WIP: WebClient -- Syntax angeglichen --- diff --git a/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java b/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java index a9ba58c..27795f9 100644 --- a/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java +++ b/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java @@ -133,21 +133,18 @@ public class GraphApiExchangeFilterFunctionIntegrationTest public Mono errorHandlingFilter(ClientRequest request, ExchangeFunction next) { - return next.exchange(request).flatMap(response -> - { - if (response.statusCode() != null && (response.statusCode() - .is5xxServerError() || response.statusCode().is4xxClientError())) - { - return response.bodyToMono(String.class) - .flatMap(errorBody -> + return + next + .exchange(request) + .flatMap(response -> { - return Mono.error(GraphApiException.create(response.statusCode(), response.headers().asHttpHeaders(), errorBody.getBytes())); + return + HttpStatus.Series.CLIENT_ERROR.equals(response.statusCode().series()) + ? response.bodyToMono(String.class).flatMap(errorBody -> + { + return Mono.error(GraphApiException.create(response.statusCode(), response.headers().asHttpHeaders(), errorBody.getBytes())); + }) + : Mono.just(response); }); - } - else - { - return Mono.just(response); - } - }); } }