FieldAccessException falls back on request errors
A field may be missing not only due to field errors but also due to a failed request, so the error message should show either, whichever is not empty. Closes gh-348
This commit is contained in:
@@ -43,13 +43,14 @@ public class FieldAccessException extends GraphQlClientException {
|
||||
public FieldAccessException(
|
||||
ClientGraphQlRequest request, ClientGraphQlResponse response, ClientResponseField field) {
|
||||
|
||||
super(initDefaultMessage(field), null, request);
|
||||
super(initDefaultMessage(field, response), null, request);
|
||||
this.response = response;
|
||||
this.field = field;
|
||||
}
|
||||
|
||||
private static String initDefaultMessage(ClientResponseField field) {
|
||||
return "Invalid field '" + field.getPath() + "', errors: " + field.getErrors();
|
||||
private static String initDefaultMessage(ClientResponseField field, ClientGraphQlResponse response) {
|
||||
return "Invalid field '" + field.getPath() + "', errors: " +
|
||||
(!field.getErrors().isEmpty() ? field.getErrors() : response.getErrors());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user