public static Mono<GraphApiException> create(ClientResponse response)
{
- return DataBufferUtils.join(response.body(BodyExtractors.toDataBuffers()))
- .map(dataBuffer -> {
- byte[] bytes = new byte[dataBuffer.readableByteCount()];
- dataBuffer.read(bytes);
- DataBufferUtils.release(dataBuffer);
- return bytes;
- })
- .defaultIfEmpty(new byte[0])
- .map(bytes -> create(response.statusCode(), response.headers().asHttpHeaders(), bytes));
+ return
+ response
+ .createException()
+ .map(we -> create(response.statusCode(), response.headers().asHttpHeaders(), we.getResponseBodyAsByteArray()));
}
public static GraphApiException create(