@@ -73,18 +73,28 @@ Here is the code for the standard behaviour.
7373
7474``` java
7575public class SimpleDataFetcherExceptionHandler implements DataFetcherExceptionHandler {
76- private static final Logger log = LoggerFactory . getLogger(SimpleDataFetcherExceptionHandler . class);
7776
78- @Override
79- public void accept (DataFetcherExceptionHandlerParameters handlerParameters ) {
80- Throwable exception = handlerParameters. getException();
81- SourceLocation sourceLocation = handlerParameters. getField(). getSourceLocation();
82- ExecutionPath path = handlerParameters. getPath();
77+ private static final Logger logNotSafe = LogKit . getNotPrivacySafeLogger(SimpleDataFetcherExceptionHandler . class);
78+
79+ static final SimpleDataFetcherExceptionHandler defaultImpl = new SimpleDataFetcherExceptionHandler ();
80+
81+ private DataFetcherExceptionHandlerResult handleExceptionImpl (DataFetcherExceptionHandlerParameters handlerParameters ) {
82+ Throwable exception = unwrap(handlerParameters. getException());
83+ SourceLocation sourceLocation = handlerParameters. getSourceLocation();
84+ ResultPath path = handlerParameters. getPath();
8385
8486 ExceptionWhileDataFetching error = new ExceptionWhileDataFetching (path, exception, sourceLocation);
85- handlerParameters. getExecutionContext(). addError(error);
86- log. warn(error. getMessage(), exception);
87+ logException(error, exception);
88+
89+ return DataFetcherExceptionHandlerResult . newResult(). error(error). build();
8790 }
91+
92+ @Override
93+ public CompletableFuture<DataFetcherExceptionHandlerResult > handleException (DataFetcherExceptionHandlerParameters handlerParameters ) {
94+ return CompletableFuture . completedFuture(handleExceptionImpl(handlerParameters));
95+ }
96+
97+ // See class for other methods
8898}
8999```
90100
@@ -127,8 +137,7 @@ behaviour.
127137``` java
128138DataFetcherExceptionHandler handler = new DataFetcherExceptionHandler () {
129139 @Override
130- public void accept (DataFetcherExceptionHandlerParameters handlerParameters ) {
131- //
140+ public CompletableFuture<DataFetcherExceptionHandlerResult > handleException (DataFetcherExceptionHandlerParameters handlerParameters ) {
132141 // do your custom handling here. The parameters have all you need
133142 }
134143};
0 commit comments