Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants