Skip to content

Commit

Permalink
Merge pull request #176 from Gigigotrek/GetRegistryByNameEmpty
Browse files Browse the repository at this point in the history
Added error control in case of GetRegistryByName not find any registry
  • Loading branch information
elenz97 authored Sep 8, 2023
2 parents e172771 + 3ecb2d4 commit 445c36d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions apiv2/pkg/clients/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ func (c *RESTClient) GetRegistryByName(ctx context.Context, name string) (*model
return nil, handleSwaggerRegistryErrors(err)
}

if len(registries) > 1 {
return nil, &errors.ErrMultipleResults{}
switch nregistries := len(registries); {
case nregistries > 1:
return nil, &errors.ErrMultipleResults{}
case nregistries == 0:
return nil, &errors.ErrRegistryNotFound{}
}
return registries[0], nil
}
Expand Down

0 comments on commit 445c36d

Please sign in to comment.