Merge pull request #4087 from cli/graphql-error-fix
Fix unmarshalling GraphQL error type
This commit is contained in:
commit
95a515ecf0
2 changed files with 2 additions and 12 deletions
|
|
@ -123,8 +123,8 @@ type graphQLResponse struct {
|
|||
// GraphQLError is a single error returned in a GraphQL response
|
||||
type GraphQLError struct {
|
||||
Type string
|
||||
Path []string
|
||||
Message string
|
||||
// Path []interface // mixed strings and numbers
|
||||
}
|
||||
|
||||
// GraphQLErrorResponse contains errors returned in a GraphQL response
|
||||
|
|
|
|||
|
|
@ -130,17 +130,7 @@ func mapRepoNameToID(client *api.Client, host, orgName string, repositoryNames [
|
|||
DatabaseID int `json:"databaseId"`
|
||||
})
|
||||
|
||||
err := client.GraphQL(host, query, nil, &graphqlResult)
|
||||
|
||||
gqlErr, isGqlErr := err.(*api.GraphQLErrorResponse)
|
||||
if isGqlErr {
|
||||
for _, ge := range gqlErr.Errors {
|
||||
if ge.Type == "NOT_FOUND" {
|
||||
return nil, fmt.Errorf("could not find %s/%s", orgName, ge.Path[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
if err := client.GraphQL(host, query, nil, &graphqlResult); err != nil {
|
||||
return nil, fmt.Errorf("failed to look up repositories: %w", err)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue