Skip to content

Commit 485d431

Browse files
committed
Update method signature, changed years ago
1 parent 9be55e5 commit 485d431

File tree

3 files changed

+57
-30
lines changed

3 files changed

+57
-30
lines changed

documentation/execution.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,28 @@ Here is the code for the standard behaviour.
7373

7474
```java
7575
public 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
128138
DataFetcherExceptionHandler 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
};

versioned_docs/version-v20/execution.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,28 @@ Here is the code for the standard behaviour.
7373

7474
```java
7575
public 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
128138
DataFetcherExceptionHandler 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
};

versioned_docs/version-v21/execution.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,28 @@ Here is the code for the standard behaviour.
7373

7474
```java
7575
public 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();
90+
}
91+
92+
@Override
93+
public CompletableFuture<DataFetcherExceptionHandlerResult> handleException(DataFetcherExceptionHandlerParameters handlerParameters) {
94+
return CompletableFuture.completedFuture(handleExceptionImpl(handlerParameters));
8795
}
96+
97+
// See class for other methods
8898
}
8999
```
90100

@@ -127,8 +137,7 @@ behaviour.
127137
```java
128138
DataFetcherExceptionHandler 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

Comments
 (0)