Skip to content

Commit

Permalink
get scorecard throws graphql error if not found
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbloss committed Oct 17, 2024
1 parent e71fb2c commit c903862
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scorecards.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package opslevel
import (
"errors"
"fmt"

"github.com/hasura/go-graphql-client"
)

type ScorecardId struct {
Expand Down Expand Up @@ -109,7 +111,10 @@ func (client *Client) GetScorecard(input string) (*Scorecard, error) {
}
err := client.Query(&q, v, WithName("ScorecardGet"))
if q.Account.Scorecard.Id == "" {
err = fmt.Errorf("scorecard with ID or Alias matching '%s' not found", input)
err = graphql.Errors{graphql.Error{
Message: fmt.Sprintf("scorecard with ID or Alias matching '%s' not found", input),
Path: []any{"account", "scorecard"},
}}
}
return &q.Account.Scorecard, HandleErrors(err, nil)
}
Expand Down

0 comments on commit c903862

Please sign in to comment.