Skip to content

Commit 859776a

Browse files
committed
- fixes #209 a bug where batch errors would not respect configured log level
1 parent b5e0deb commit 859776a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/main/java/com/microsoft/graph/content/BatchResponseStep.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
import com.microsoft.graph.http.GraphErrorResponse;
3434
import com.microsoft.graph.http.GraphFatalServiceException;
3535
import com.microsoft.graph.http.GraphServiceException;
36+
import com.microsoft.graph.logger.ILogger;
37+
import com.microsoft.graph.logger.LoggerLevel;
38+
import com.microsoft.graph.serializer.DefaultSerializer;
3639
import com.microsoft.graph.serializer.ISerializer;
3740

3841
/** Response for the batch step */
@@ -61,7 +64,13 @@ public <T2> T2 getDeserializedBody(@Nonnull final Class<T2> resultClass) throws
6164
final GraphErrorResponse error = serializer.deserializeObject((JsonElement)body, GraphErrorResponse.class);
6265
if(error == null || error.error == null) {
6366
return serializer.deserializeObject((JsonElement)body, resultClass);
64-
} else
65-
throw GraphServiceException.createFromResponse("", "", new ArrayList<>(), "", headers, "", status, error, false);
67+
} else {
68+
boolean verboseError = false;
69+
if(serializer instanceof DefaultSerializer) {
70+
final ILogger logger = ((DefaultSerializer)serializer).getLogger();
71+
verboseError = logger != null && logger.getLoggingLevel() == LoggerLevel.DEBUG;
72+
}
73+
throw GraphServiceException.createFromResponse("", "", new ArrayList<>(), "", headers, "", status, error, verboseError);
74+
}
6675
}
6776
}

src/main/java/com/microsoft/graph/serializer/DefaultSerializer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,6 @@ public Class<?> getDerivedClass(@Nonnull final JsonObject jsonObject, @Nullable
393393
*
394394
* @return a logger
395395
*/
396-
@VisibleForTesting
397396
@Nullable
398397
public ILogger getLogger() {
399398
return logger;

0 commit comments

Comments
 (0)