Skip to content

Commit 8d8432d

Browse files
committed
Consistent logging in annotated exception handler
This commit aligns DEBUG logging of exceptions resolved via annotated exception handler methods with ExceptionResolversExceptionHandler and the reference documentation. Closes gh-996
1 parent 9f49103 commit 8d8432d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/AnnotatedControllerExceptionResolver.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,17 @@ private Mono<List<GraphQLError>> invokeExceptionHandler(
238238

239239
Object result = exceptionHandler.invoke(env, arguments);
240240

241-
return methodReturnValueAdapter.adapt(result, exception);
241+
Mono<List<GraphQLError>> errorsMono = methodReturnValueAdapter.adapt(result, exception);
242+
if (logger.isDebugEnabled()) {
243+
errorsMono = errorsMono.doOnNext((errors) -> {
244+
if (logger.isDebugEnabled()) {
245+
String name = exception.getClass().getSimpleName();
246+
logger.debug("Resolved " + name + " to GraphQL error(s): " + errors, exception);
247+
}
248+
});
249+
}
250+
251+
return errorsMono;
242252
}
243253
catch (Throwable invocationEx) {
244254
// Any other than the original exception (or a cause) is unintended here,

0 commit comments

Comments
 (0)