Skip to content

Commit

Permalink
Access err
Browse files Browse the repository at this point in the history
  • Loading branch information
whywaita committed Sep 21, 2024
1 parent 93572ec commit 1e7f722
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/starter/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ var (
ErrInvalidLabel = Error{kind: errorInvalidLabel, err: nil}
)

func NewInvalidLabel(err error) error {
e := ErrInvalidLabel
e.err = err
return e
}

func (e Error) Is(target error) bool {
var t Error
ok := errors.As(target, &t)
Expand Down
2 changes: 1 addition & 1 deletion pkg/starter/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (s *Starter) bung(ctx context.Context, job datastore.Job, target datastore.
cloudID, ipAddress, shoesType, resourceType, err := client.AddInstance(ctx, runnerName, script, target.ResourceType, labels)
if err != nil {
if stat, _ := status.FromError(err); stat.Code() == codes.InvalidArgument {
return "", "", "", datastore.ResourceTypeUnknown, ErrInvalidLabel
return "", "", "", datastore.ResourceTypeUnknown, NewInvalidLabel(err)
}
return "", "", "", datastore.ResourceTypeUnknown, fmt.Errorf("failed to add instance: %w", err)
}
Expand Down

0 comments on commit 1e7f722

Please sign in to comment.