Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,7 @@ public String getMessage(final boolean verbose) {
if (verbose) {
sb.append(requestBody);
} else {
final int bodyLength = Math.min(MAX_BREVITY_LENGTH, requestBody.length());
final String truncatedBody = requestBody.substring(0, bodyLength);
sb.append(truncatedBody);
if (truncatedBody.length() == MAX_BREVITY_LENGTH) {
sb.append(TRUNCATION_MARKER);
}
sb.append(TRUNCATION_MARKER);
}
}
sb.append(NEW_LINE).append(NEW_LINE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected LargeFileUploadResponse(@Nullable final ClientException error) {
protected LargeFileUploadResponse(@Nonnull final GraphServiceException exception) {
this(new ClientException(Objects
.requireNonNull(exception, "parameter exception cannot be null")
.getMessage(/* verbose */ true),
.getMessage(),
exception));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,24 @@ public void testcreateFromResponse() throws IOException {
String message = exception.getMessage();
assertTrue(message.indexOf("http://localhost") > 0);
}
@Test
public void requestPayloadShouldNotBePartOfMessageWhenNotVerbose(){
final GraphErrorResponse errorResponse = new GraphErrorResponse();
final GraphError error = new GraphError();
error.code = GraphErrorCodes.UNAUTHENTICATED.toString();
errorResponse.error = error;
final GraphServiceException exception = new GraphServiceException("GET","https://graph.microsoft.com/v1.0/me",new ArrayList<String>(),"requestPayload",401,"Unauthorized",new ArrayList<String>(),errorResponse, false);
final String message = exception.getMessage();
assertFalse(message.indexOf("requestPayload") > 0);
}
@Test
public void requestPayloadShouldBePartOfMessageWhenVerbose(){
final GraphErrorResponse errorResponse = new GraphErrorResponse();
final GraphError error = new GraphError();
error.code = GraphErrorCodes.UNAUTHENTICATED.toString();
errorResponse.error = error;
final GraphServiceException exception = new GraphServiceException("GET","https://graph.microsoft.com/v1.0/me",new ArrayList<String>(),"requestPayload",401,"Unauthorized",new ArrayList<String>(),errorResponse, true);
final String message = exception.getMessage();
assertTrue(message.indexOf("requestPayload") > 0);
}
}