Skip to content

Commit 3a37025

Browse files
authored
refactor: include more info in Microsoft stacktrace, when/if available (#1460)
nit: bodyException() is being populated but never read, which someone… will *really* not appreciate when they try to make sense of a stacktrace some day
1 parent a649900 commit 3a37025

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

  • extensions/data-transfer/portability-data-transfer-microsoft/src/main/java/org/datatransferproject/transfer/microsoft

extensions/data-transfer/portability-data-transfer-microsoft/src/main/java/org/datatransferproject/transfer/microsoft/MicrosoftApiResponse.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,14 @@ public String getJsonValue(ObjectMapper objectMapper, String jsonTopKey, String
277277

278278
/** Returns response body or throws DTP base exception with `causeMessage`. */
279279
private String checkResponseBody(String causeMessage) throws IOException {
280-
return body()
281-
.orElseThrow(
282-
() ->
283-
toIoException(
284-
String.format("HTTP response-body unexpectedly empty: %s", causeMessage)));
280+
return body().orElseThrow(() -> {
281+
final String causeWithContext = String.format("HTTP response-body unexpectedly empty: %s", causeMessage);
282+
if (bodyException().isPresent()) {
283+
return toIoException(causeWithContext, bodyException().get());
284+
} else {
285+
return toIoException(causeWithContext);
286+
}
287+
});
285288
}
286289

287290
/** Reads body into memory and checks for needle. */

0 commit comments

Comments
 (0)