Skip to content

Commit

Permalink
Add GitHub error type to GraphQL error messages. (#532)
Browse files Browse the repository at this point in the history
* Add GitHub error type to GraphQL error messages.

This is to help fix error handling when new errors are encountered.

Signed-off-by: Caleb Brown <[email protected]>

* Update error test to include github type.

Signed-off-by: Caleb Brown <[email protected]>

---------

Signed-off-by: Caleb Brown <[email protected]>
  • Loading branch information
calebbrown authored Feb 1, 2024
1 parent cf823f1 commit e0b4b1a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/githubapi/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (e *GraphQLErrors) Error() string {
case 0:
panic("no errors found")
case 1:
return e.errors[0].Message
return fmt.Sprintf("%s (type: %s)", e.errors[0].Message, e.errors[0].Type)
default:
return fmt.Sprintf("%d GraphQL errors", len(e.errors))
}
Expand Down
4 changes: 2 additions & 2 deletions internal/githubapi/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ func TestGraphQLErrors_Error(t *testing.T) {
{
name: "one error",
errors: []GraphQLError{
{Message: "one"},
{Message: "one", Type: "A_TYPE"},
},
want: "one",
want: "one (type: A_TYPE)",
},
{
name: "more than one error",
Expand Down

0 comments on commit e0b4b1a

Please sign in to comment.