Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors #93

Open
luziyuan002 opened this issue Nov 15, 2019 · 2 comments
Open

errors #93

luziyuan002 opened this issue Nov 15, 2019 · 2 comments

Comments

@luziyuan002
Copy link

Rejoiner's errors make me feel inconvenient because I can't define valid data to let the front desk staff know what the current error is, what kind of error is, because the current valid information is only message, which is not good judgment, I hope in When you execute responseObserver.onError(), you can have some properties in the error message, you can customize it, and let the background personnel return their own defined errors.

@LIU0472
Copy link

LIU0472 commented Nov 17, 2019

static class SampleGraphQLException extends RuntimeException implements GraphQLError {
@Override
public String getMessage() {
return "Test GraphQLError";
}
@Override
public List<SourceLocation> getLocations() {
return null;
}
@Override
public ErrorType getErrorType() {
return ErrorType.DataFetchingException;
}
@Override
public Map<String, Object> getExtensions() {
HashMap<String, Object> extensions = Maps.newHashMap();
extensions.put("error", "message");
return extensions;
}
}

@Query("greetingWithGraphQLError")
ListenableFuture<GreetingsResponse> greetingsWithGraphqlError(GreetingsRequest request) {
throw new SampleGraphQLException();
}
}

@luziyuan002

@luziyuan002
Copy link
Author

static class SampleGraphQLException extends RuntimeException implements GraphQLError {
@Override
public String getMessage() {
return "Test GraphQLError";
}
@Override
public List<SourceLocation> getLocations() {
return null;
}
@Override
public ErrorType getErrorType() {
return ErrorType.DataFetchingException;
}
@Override
public Map<String, Object> getExtensions() {
HashMap<String, Object> extensions = Maps.newHashMap();
extensions.put("error", "message");
return extensions;
}
}

@Query("greetingWithGraphQLError")
ListenableFuture<GreetingsResponse> greetingsWithGraphqlError(GreetingsRequest request) {
throw new SampleGraphQLException();
}
}

@luziyuan002

Thank you, I think I know what to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants