From 1f9541d29b78e976f3355d51b166647abfb6aa7a Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Tue, 28 Oct 2014 02:19:09 -0700 Subject: [PATCH 1/6] refactor(blockservice) export blockservice.ErrNotFound --- blockservice/blockservice.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/blockservice/blockservice.go b/blockservice/blockservice.go index acb6564ed63..54a992cdb6e 100644 --- a/blockservice/blockservice.go +++ b/blockservice/blockservice.go @@ -1,6 +1,7 @@ package blockservice import ( + "errors" "fmt" context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" @@ -13,6 +14,7 @@ import ( ) var log = u.Logger("blockservice") +var ErrNotFound = errors.New("blockservice: key not found") // BlockService is a block datastore. // It uses an internal `datastore.Datastore` instance to store values. @@ -73,7 +75,7 @@ func (s *BlockService) GetBlock(ctx context.Context, k u.Key) (*blocks.Block, er return blk, nil } else { log.Debug("Blockservice GetBlock: Not found.") - return nil, u.ErrNotFound + return nil, ErrNotFound } } From 04e270a91e0950850ef191e71f38e0f3bd2d642b Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Tue, 28 Oct 2014 02:21:20 -0700 Subject: [PATCH 2/6] refactor(merkledag) use one-off error --- merkledag/merkledag.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/merkledag/merkledag.go b/merkledag/merkledag.go index 0e595c9d693..014fcec8056 100644 --- a/merkledag/merkledag.go +++ b/merkledag/merkledag.go @@ -103,7 +103,7 @@ func (n *Node) RemoveNodeLink(name string) error { return nil } } - return u.ErrNotFound + return fmt.Errorf("merkledag: %s not found", name) } // Copy returns a copy of the node. From c534daef8668f85e272b8155bcb1c87005e9b1eb Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Tue, 28 Oct 2014 02:22:32 -0700 Subject: [PATCH 3/6] refactor(namesys) use one-off error --- namesys/dns.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/namesys/dns.go b/namesys/dns.go index 66448511f85..655e910b86a 100644 --- a/namesys/dns.go +++ b/namesys/dns.go @@ -1,13 +1,12 @@ package namesys import ( + "fmt" "net" b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58" isd "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-is-domain" mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" - - u "github.com/jbenet/go-ipfs/util" ) // DNSResolver implements a Resolver on DNS domains @@ -44,5 +43,5 @@ func (r *DNSResolver) Resolve(name string) (string, error) { return t, nil } - return "", u.ErrNotFound + return "", fmt.Errorf("namesys: %v not found", name) } From 0bfadea0366a7997ddb2d6200124a8edbdc6d3cc Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Tue, 28 Oct 2014 15:40:26 -0700 Subject: [PATCH 4/6] fix(namesys, merkledag) use static error --- merkledag/merkledag.go | 1 + namesys/dns.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/merkledag/merkledag.go b/merkledag/merkledag.go index 014fcec8056..c0a37bd24b4 100644 --- a/merkledag/merkledag.go +++ b/merkledag/merkledag.go @@ -13,6 +13,7 @@ import ( ) var log = u.Logger("merkledag") +var ErrNotFound = fmt.Errorf("merkledag: not found") // NodeMap maps u.Keys to Nodes. // We cannot use []byte/Multihash for keys :( diff --git a/namesys/dns.go b/namesys/dns.go index 655e910b86a..847ed067010 100644 --- a/namesys/dns.go +++ b/namesys/dns.go @@ -9,6 +9,8 @@ import ( mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" ) +var ErrNotFound = fmt.Errorf("namesys: name not found") + // DNSResolver implements a Resolver on DNS domains type DNSResolver struct { // TODO: maybe some sort of caching? @@ -43,5 +45,5 @@ func (r *DNSResolver) Resolve(name string) (string, error) { return t, nil } - return "", fmt.Errorf("namesys: %v not found", name) + return "", ErrNotFound } From edbaa3f664921b9132f24bc7bc62b3b390837e5d Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Tue, 28 Oct 2014 15:41:49 -0700 Subject: [PATCH 5/6] fix(namesys) use the error that already exists --- namesys/dns.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/namesys/dns.go b/namesys/dns.go index 847ed067010..881979930a0 100644 --- a/namesys/dns.go +++ b/namesys/dns.go @@ -1,7 +1,6 @@ package namesys import ( - "fmt" "net" b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58" @@ -9,8 +8,6 @@ import ( mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" ) -var ErrNotFound = fmt.Errorf("namesys: name not found") - // DNSResolver implements a Resolver on DNS domains type DNSResolver struct { // TODO: maybe some sort of caching? @@ -45,5 +42,5 @@ func (r *DNSResolver) Resolve(name string) (string, error) { return t, nil } - return "", ErrNotFound + return "", ErrResolveFailed } From 9a9dc926b5bb83b303e8ca5ae144d7fc6e7f9432 Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Tue, 28 Oct 2014 16:10:17 -0700 Subject: [PATCH 6/6] fix(merkledag) return static error --- merkledag/merkledag.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/merkledag/merkledag.go b/merkledag/merkledag.go index c0a37bd24b4..a7eb05d7c61 100644 --- a/merkledag/merkledag.go +++ b/merkledag/merkledag.go @@ -104,7 +104,7 @@ func (n *Node) RemoveNodeLink(name string) error { return nil } } - return fmt.Errorf("merkledag: %s not found", name) + return ErrNotFound } // Copy returns a copy of the node.