X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fde%2Fjuplo%2Ffacebook%2Ferrors%2FGraphApiException.java;h=3f9c54485e3ece2e2f0e01ec17364cbfeee4b49d;hb=b1a46d53733d1847b175fad2d8259371d4c6380f;hp=2e56e62e0c37e0bdfdb3e9949f10dc929c957c69;hpb=14d0788aed0305a814fc87bc33f3f17771dc6858;p=facebook-errors diff --git a/src/main/java/de/juplo/facebook/errors/GraphApiException.java b/src/main/java/de/juplo/facebook/errors/GraphApiException.java index 2e56e62..3f9c544 100644 --- a/src/main/java/de/juplo/facebook/errors/GraphApiException.java +++ b/src/main/java/de/juplo/facebook/errors/GraphApiException.java @@ -12,6 +12,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; +import org.springframework.http.ReactiveHttpInputMessage; +import org.springframework.web.reactive.function.BodyExtractor; +import org.springframework.web.reactive.function.BodyExtractor.Context; import org.springframework.web.reactive.function.client.ClientResponse; import reactor.core.publisher.Mono; @@ -47,11 +50,10 @@ public class GraphApiException extends RuntimeException public static GraphApiException create(ClientResponse response) { - Mono body = - response - .bodyToMono(String.class); - Mono e = body - .map(str -> create(response.statusCode(), null, str.getBytes())); + HttpStatus status = response.statusCode(); + HttpHeaders headers = response.headers().asHttpHeaders(); + Mono body = response.bodyToMono(String.class); + return create(status , headers, body.block().getBytes()); } public static GraphApiException create(