graphql.execution.SimpleDataFetcherExceptionHandler Maven / Gradle / Ivy
package graphql.execution;
import graphql.ExceptionWhileDataFetching;
import graphql.PublicApi;
import graphql.language.SourceLocation;
import graphql.util.LogKit;
import org.slf4j.Logger;
/**
* The standard handling of data fetcher error involves placing a {@link ExceptionWhileDataFetching} error
* into the error collection
*/
@PublicApi
public class SimpleDataFetcherExceptionHandler implements DataFetcherExceptionHandler {
private static final Logger logNotSafe = LogKit.getNotPrivacySafeLogger(SimpleDataFetcherExceptionHandler.class);
@Override
public DataFetcherExceptionHandlerResult onException(DataFetcherExceptionHandlerParameters handlerParameters) {
Throwable exception = handlerParameters.getException();
SourceLocation sourceLocation = handlerParameters.getSourceLocation();
ResultPath path = handlerParameters.getPath();
ExceptionWhileDataFetching error = new ExceptionWhileDataFetching(path, exception, sourceLocation);
logNotSafe.warn(error.getMessage(), exception);
return DataFetcherExceptionHandlerResult.newResult().error(error).build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy