WIP: WebClient -- DIE LĂ–SUNG!
[facebook-errors] / src / main / java / de / juplo / facebook / errors / GraphApiExchangeFilterFunction.java
index 6642e38..768ec1d 100644 (file)
@@ -30,12 +30,16 @@ public class GraphApiExchangeFilterFunction implements ExchangeFilterFunction
     return
         next
             .exchange(request)
-            .doOnError(e -> LOG.debug("ERROR: {}", e))
             .flatMap(response ->
             {
               return
                   HttpStatus.Series.CLIENT_ERROR.equals(response.statusCode().series())
-                      ? Mono.error(GraphApiException.create(response).block())
+                      ? response
+                          .bodyToMono(String.class)
+                          .flatMap(errorBody -> Mono.error(GraphApiException.create(
+                              response.statusCode(),
+                              response.headers().asHttpHeaders(),
+                              errorBody.getBytes())))
                       : Mono.just(response);
             });
   }