Skip to content

Commit e6367fa

Browse files
committed
Revert "Handle GraphQLError exceptions and unwrapping of CompletionExceptions"
This reverts commit 57b6d1a
1 parent 57b6d1a commit e6367fa

2 files changed

Lines changed: 7 additions & 116 deletions

File tree

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package graphql.execution;
22

33
import graphql.ExceptionWhileDataFetching;
4-
import graphql.GraphQLError;
54
import graphql.PublicApi;
5+
import graphql.language.SourceLocation;
66
import graphql.util.LogKit;
77
import org.slf4j.Logger;
88

9-
import java.util.concurrent.CompletionException;
10-
119
/**
1210
* The standard handling of data fetcher error involves placing a {@link ExceptionWhileDataFetching} error
1311
* into the error collection
@@ -19,28 +17,13 @@ public class SimpleDataFetcherExceptionHandler implements DataFetcherExceptionHa
1917

2018
@Override
2119
public DataFetcherExceptionHandlerResult onException(DataFetcherExceptionHandlerParameters handlerParameters) {
22-
Throwable exception = unwrap(handlerParameters.getException());
23-
GraphQLError error;
24-
if (exception instanceof GraphQLError) {
25-
error = (GraphQLError) exception;
26-
} else {
27-
error = new ExceptionWhileDataFetching(handlerParameters.getPath(), exception, handlerParameters.getSourceLocation());
28-
}
20+
Throwable exception = handlerParameters.getException();
21+
SourceLocation sourceLocation = handlerParameters.getSourceLocation();
22+
ResultPath path = handlerParameters.getPath();
23+
24+
ExceptionWhileDataFetching error = new ExceptionWhileDataFetching(path, exception, sourceLocation);
2925
logNotSafe.warn(error.getMessage(), exception);
30-
return DataFetcherExceptionHandlerResult.newResult().error(error).build();
31-
}
3226

33-
/**
34-
* Called to unwrap an exception to a more suitable cause if required
35-
*
36-
* @param exception the exception to unwrap
37-
*
38-
* @return the suitable exception
39-
*/
40-
protected Throwable unwrap(Throwable exception) {
41-
if (exception instanceof CompletionException) {
42-
return exception.getCause();
43-
}
44-
return exception;
27+
return DataFetcherExceptionHandlerResult.newResult().error(error).build();
4528
}
4629
}

‎src/test/groovy/graphql/execution/SimpleDataFetcherExceptionHandlerTest.groovy‎

Lines changed: 0 additions & 92 deletions
This file was deleted.

0 commit comments

Comments
 (0)