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
This commit is contained in:
rstoyanchev
2024-06-26 13:12:45 +01:00
parent 9f49103c65
commit 8d8432db44

View File

@@ -238,7 +238,17 @@ final class AnnotatedControllerExceptionResolver implements HandlerDataFetcherEx
Object result = exceptionHandler.invoke(env, arguments);
return methodReturnValueAdapter.adapt(result, exception);
Mono<List<GraphQLError>> errorsMono = methodReturnValueAdapter.adapt(result, exception);
if (logger.isDebugEnabled()) {
errorsMono = errorsMono.doOnNext((errors) -> {
if (logger.isDebugEnabled()) {
String name = exception.getClass().getSimpleName();
logger.debug("Resolved " + name + " to GraphQL error(s): " + errors, exception);
}
});
}
return errorsMono;
}
catch (Throwable invocationEx) {
// Any other than the original exception (or a cause) is unintended here,