Skip to content

Commit

Permalink
container: clarify returned error
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMure committed Jan 13, 2025
1 parent 10dd4fa commit 6d7fd28
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pkg/container/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package container

import (
"bytes"
"errors"
"fmt"
"io"
"iter"
Expand Down Expand Up @@ -101,14 +100,12 @@ func (ctn Reader) GetToken(cid cid.Cid) (token.Token, error) {
}

// GetDelegation is the same as GetToken but only return a delegation.Token, with the right type.
// If not found, delegation.ErrDelegationNotFound is returned.
func (ctn Reader) GetDelegation(cid cid.Cid) (*delegation.Token, error) {
tkn, err := ctn.GetToken(cid)
if errors.Is(err, ErrNotFound) {
if err != nil { // only ErrNotFound expected
return nil, delegation.ErrDelegationNotFound
}
if err != nil {
return nil, err
}
if tkn, ok := tkn.(*delegation.Token); ok {
return tkn, nil
}
Expand Down

0 comments on commit 6d7fd28

Please sign in to comment.