提交 e8fcd199 作者: Jeromy

return a better error if the ref is not an object

License: MIT
Signed-off-by: 's avatarJeromy <why@ipfs.io>
上级 7d18f748
...@@ -3,6 +3,7 @@ package merkledag ...@@ -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) { ...@@ -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("%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
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论