Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions auto_submit/lib/service/graphql_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,17 @@ class GraphQlService {

if (queryResult.hasException) {
log.error('GraphQL query failed', queryResult.exception);
throw const BadRequestException('GraphQL query failed');
final exception = queryResult.exception!;
final errors = exception.graphqlErrors;
String errorMessage;
if (errors.isNotEmpty) {
errorMessage = errors.map((e) => e.message).join(', ');
} else if (exception.linkException != null) {
errorMessage = exception.linkException.toString();
} else {
errorMessage = 'GraphQL query failed';
}
throw BadRequestException(errorMessage);
}
return queryResult.data!;
}
Expand All @@ -67,7 +77,17 @@ class GraphQlService {

if (queryResult.hasException) {
log.error('GraphQL mutate failed', queryResult.exception);
throw const BadRequestException('GraphQL mutate failed');
final exception = queryResult.exception!;
final errors = exception.graphqlErrors;
String errorMessage;
if (errors.isNotEmpty) {
errorMessage = errors.map((e) => e.message).join(', ');
} else if (exception.linkException != null) {
errorMessage = exception.linkException.toString();
} else {
errorMessage = 'GraphQL mutate failed';
}
throw BadRequestException(errorMessage);
}
return queryResult.data!;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,14 @@ This is the second line in a paragraph.''');
return QueryResult(
options: options,
source: QueryResultSource.network,
exception: OperationException(),
exception: OperationException(
graphqlErrors: <GraphQLError>[
const GraphQLError(
message:
'Pull request New changes require approval from someone other than Piinks because they were the last pusher.',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, bad Piinks.

),
],
),
);
};

Expand All @@ -648,7 +655,7 @@ This is the second line in a paragraph.''');
expect(
result.message,
contains(
'Failed to enqueue flutter/flutter/42 with HTTP 400: GraphQL mutate failed',
'Failed to enqueue flutter/flutter/42 with HTTP 400: Pull request New changes require approval from someone other than Piinks because they were the last pusher.',
),
);
});
Expand Down
Loading