mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-27 07:57:30 +08:00
Merge pull request #2886 from ipfs/feat/not-object-error
return a better error if the ref is not an object
This commit is contained in:
@ -3,6 +3,7 @@ package merkledag
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
blocks "github.com/ipfs/go-ipfs/blocks"
|
blocks "github.com/ipfs/go-ipfs/blocks"
|
||||||
@ -87,6 +88,9 @@ func (n *dagService) Get(ctx context.Context, k key.Key) (*Node, error) {
|
|||||||
|
|
||||||
res, err := DecodeProtobuf(b.Data())
|
res, err := DecodeProtobuf(b.Data())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if strings.Contains(err.Error(), "Unmarshal failed") {
|
||||||
|
return nil, fmt.Errorf("The block referred to by '%s' was not a valid merkledag node", k)
|
||||||
|
}
|
||||||
return nil, fmt.Errorf("Failed to decode Protocol Buffers: %v", err)
|
return nil, fmt.Errorf("Failed to decode Protocol Buffers: %v", err)
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
|
Reference in New Issue
Block a user