@cryptotaxi247 / kubo / commits / e8fcd1996

return a better error if the ref is not an object

License: MIT Signed-off-by: Jeromy <why@ipfs.io>

Jeromy committed Jun 21, 2016 at 13:59 UTC e8fcd199698dd18b3f6d45f7f88456aa74236a4e
1 file changed +4
merkledag/merkledag.go
+4
@@ -3,6 +3,7 @@ package merkledag
3
4 import (
5 "fmt"
6 + "strings"
7 "sync"
8
9 blocks "github.com/ipfs/go-ipfs/blocks"
@@ -87,6 +88,9 @@ func (n *dagService) Get(ctx context.Context, k key.Key) (*Node, error) {
88
89 res, err := DecodeProtobuf(b.Data())
90 if err != nil {
91 + if strings.Contains(err.Error(), "Unmarshal failed") {
92 + return nil, fmt.Errorf("%s was not a valid merkledag node", k)
93 + }
94 return nil, fmt.Errorf("Failed to decode Protocol Buffers: %v", err)
95 }
96 return res, nil