use of graphql.GraphqlErrorBuilder in project graphql-java-extended-validation by graphql-java.
the class ResourceBundleMessageInterpolator method interpolate.
@Override
public GraphQLError interpolate(String messageTemplate, Map<String, Object> messageParams, ValidationEnvironment validationEnvironment) {
ErrorClassification errorClassification = buildErrorClassification(messageTemplate, messageParams, validationEnvironment);
String message = interpolateMessageImpl(messageTemplate, messageParams, validationEnvironment);
GraphqlErrorBuilder errorBuilder = GraphqlErrorBuilder.newError().message(message).errorType(errorClassification).path(validationEnvironment.getExecutionPath());
if (validationEnvironment.getLocation() != null) {
errorBuilder.location(validationEnvironment.getLocation());
}
return errorBuilder.build();
}
use of graphql.GraphqlErrorBuilder in project teamcity-rest by JetBrains.
the class ResolverExceptionHandler method onException.
@Override
public DataFetcherExceptionHandlerResult onException(DataFetcherExceptionHandlerParameters handlerParameters) {
Throwable exception = handlerParameters.getException();
SourceLocation sourceLocation = handlerParameters.getSourceLocation();
ExecutionPath path = handlerParameters.getPath();
GraphqlErrorBuilder builder = GraphqlErrorBuilder.newError().path(path).location(sourceLocation);
if (exception.getMessage() != null) {
builder.message(exception.getMessage());
} else {
builder.message(exception.getClass().getSimpleName());
}
if (exception instanceof AccessDeniedException) {
GraphQLError error = builder.errorType(TeamCityGraphQLErrorType.ACCESS_DENIED).build();
return DataFetcherExceptionHandlerResult.newResult().error(error).build();
}
if (exception instanceof NotFoundException) {
GraphQLError error = builder.errorType(TeamCityGraphQLErrorType.NOT_FOUND).build();
return DataFetcherExceptionHandlerResult.newResult().error(error).build();
}
LOG.warnAndDebugDetails("Exception occured while fetching data.", exception);
GraphQLError error = builder.errorType(TeamCityGraphQLErrorType.SERVER_ERROR).build();
return DataFetcherExceptionHandlerResult.newResult().error(error).build();
}
Aggregations