remove debugerrors
We now consider debugerrors harmful: we've run into cases where debugerror.Wrap() hid valuable error information (err == io.EOF?). I've removed them from the main code, but left them in some tests. Go errors are lacking, but unfortunately, this isn't the solution. It is possible that debugerros.New or debugerrors.Errorf should remain still (i.e. only remove debugerrors.Wrap) but we don't use these errors often enough to keep.
Juan Batiz-Benet committed
Apr 20, 2015 at 00:15 UTC
140cd1fd1bde9c199e8c172ca9898506c23cead0
30 files changed
+80
-81
assets/contact.go
+1
@@ -1,4 +1,5 @@
1
package assets
2
+
3
var Init_doc_contact = `Come hang out in our IRC chat room if you have any questions.
4
5
Contact the ipfs dev team:
assets/help.go
+1
@@ -1,4 +1,5 @@
1
package assets
2
+
3
var Init_doc_help = `Some helpful resources for finding your way around ipfs:
4
5
- quick-start: a quick show of various ipfs features.
assets/quick-start.go
+1
@@ -1,4 +1,5 @@
1
package assets
2
+
3
var Init_doc_quick_start = `# 0.1 - Quick Start
4
5
This is a set of short examples with minmal explanation. It is meant as
assets/readme.go
+1
@@ -1,4 +1,5 @@
1
package assets
2
+
3
var Init_doc_readme = `Hello and Welcome to IPFS!
4
5
██╗██████╗ ███████╗███████╗
assets/security-notes.go
+1
@@ -1,4 +1,5 @@
1
package assets
2
+
3
var Init_doc_security_notes = ` IPFS Alpha Security Notes
4
5
We try hard to ensure our system is safe and robust, but all software
cmd/ipfs/daemon.go
+3
-4
@@ -14,7 +14,6 @@ import (
14
peer "github.com/ipfs/go-ipfs/p2p/peer"
15
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"
16
util "github.com/ipfs/go-ipfs/util"
17
- "github.com/ipfs/go-ipfs/util/debugerror"
17
)
18
19
const (
@@ -56,7 +55,7 @@ in the network, use 0.0.0.0 as the ip address:
55
56
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
57
59
-Be careful if you expose the API. It is a security risk, as anyone could use control
58
+Be careful if you expose the API. It is a security risk, as anyone could use control
59
your node remotely. If you need to control the node remotely, make sure to protect
60
the port as you would other services or database (firewall, authenticated proxy, etc).`,
61
},
@@ -98,7 +97,7 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
97
if !util.FileExists(req.Context().ConfigRoot) {
98
err := initWithDefaults(os.Stdout, req.Context().ConfigRoot)
99
if err != nil {
101
- res.SetError(debugerror.Wrap(err), cmds.ErrNormal)
100
+ res.SetError(err, cmds.ErrNormal)
101
return
102
}
103
}
@@ -120,7 +119,7 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
119
// sure we are permitted to access the resources (datastore, etc.)
120
repo, err := fsrepo.Open(req.Context().ConfigRoot)
121
if err != nil {
123
- res.SetError(debugerror.Errorf("Couldn't obtain lock. Is another daemon already running?"), cmds.ErrNormal)
122
+ res.SetError(fmt.Errorf("Couldn't obtain lock. Is another daemon already running?"), cmds.ErrNormal)
123
return
124
}
125
cmd/ipfs/init.go
+3
-3
@@ -2,6 +2,7 @@ package main
2
3
import (
4
"bytes"
5
+ "errors"
6
"fmt"
7
"io"
8
@@ -15,7 +16,6 @@ import (
16
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"
17
uio "github.com/ipfs/go-ipfs/unixfs/io"
18
u "github.com/ipfs/go-ipfs/util"
18
- debugerror "github.com/ipfs/go-ipfs/util/debugerror"
19
)
20
21
const nBitsForKeypairDefault = 4096
@@ -65,14 +65,14 @@ var initCmd = &cmds.Command{
65
},
66
}
67
68
-var errRepoExists = debugerror.New(`ipfs configuration file already exists!
68
+var errRepoExists = errors.New(`ipfs configuration file already exists!
69
Reinitializing would overwrite your keys.
70
(use -f to force overwrite)
71
`)
72
73
func initWithDefaults(out io.Writer, repoRoot string) error {
74
err := doInit(out, repoRoot, false, nBitsForKeypairDefault)
75
- return debugerror.Wrap(err)
75
+ return err
76
}
77
78
func doInit(out io.Writer, repoRoot string, force bool, nBitsForKeypair int) error {
cmd/ipfs/main.go
+1
-2
@@ -26,7 +26,6 @@ import (
26
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"
27
eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog"
28
u "github.com/ipfs/go-ipfs/util"
29
- "github.com/ipfs/go-ipfs/util/debugerror"
29
)
30
31
// log is the command logger
@@ -355,7 +354,7 @@ func commandDetails(path []string, root *cmds.Command) (*cmdDetails, error) {
354
var found bool
355
cmd, found = cmd.Subcommands[cmp]
356
if !found {
358
- return nil, debugerror.Errorf("subcommand %s should be in root", cmp)
357
+ return nil, fmt.Errorf("subcommand %s should be in root", cmp)
358
}
359
360
if cmdDetails, found := cmdDetailsMap[cmd]; found {
core/commands/add.go
+3
-4
@@ -18,7 +18,6 @@ import (
18
dag "github.com/ipfs/go-ipfs/merkledag"
19
ft "github.com/ipfs/go-ipfs/unixfs"
20
u "github.com/ipfs/go-ipfs/util"
21
- "github.com/ipfs/go-ipfs/util/debugerror"
21
)
22
23
// Error indicating the max depth has been exceded.
@@ -106,19 +105,19 @@ remains to be implemented.
105
106
rootnd, err := addFile(n, file, outChan, progress, wrap)
107
if err != nil {
109
- res.SetError(debugerror.Wrap(err), cmds.ErrNormal)
108
+ res.SetError(err, cmds.ErrNormal)
109
return
110
}
111
112
err = n.Pinning.Pin(context.Background(), rootnd, true)
113
if err != nil {
115
- res.SetError(debugerror.Wrap(err), cmds.ErrNormal)
114
+ res.SetError(err, cmds.ErrNormal)
115
return
116
}
117
118
err = n.Pinning.Flush()
119
if err != nil {
121
- res.SetError(debugerror.Wrap(err), cmds.ErrNormal)
120
+ res.SetError(err, cmds.ErrNormal)
121
return
122
}
123
}
core/commands/bootstrap.go
+1
-1
@@ -2,6 +2,7 @@ package commands
2
3
import (
4
"bytes"
5
+ "errors"
6
"io"
7
"sort"
8
@@ -10,7 +11,6 @@ import (
11
config "github.com/ipfs/go-ipfs/repo/config"
12
"github.com/ipfs/go-ipfs/repo/fsrepo"
13
u "github.com/ipfs/go-ipfs/util"
13
- errors "github.com/ipfs/go-ipfs/util/debugerror"
14
)
15
16
type BootstrapOutput struct {
core/commands/swarm.go
+1
-1
@@ -2,13 +2,13 @@ package commands
2
3
import (
4
"bytes"
5
+ "errors"
6
"fmt"
7
"io"
8
"sort"
9
10
cmds "github.com/ipfs/go-ipfs/commands"
11
peer "github.com/ipfs/go-ipfs/p2p/peer"
11
- errors "github.com/ipfs/go-ipfs/util/debugerror"
12
iaddr "github.com/ipfs/go-ipfs/util/ipfsaddr"
13
14
ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
core/core.go
+18
-18
@@ -3,6 +3,7 @@
3
package core
4
5
import (
6
+ "errors"
7
"fmt"
8
"io"
9
"time"
@@ -14,7 +15,6 @@ import (
15
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
16
metrics "github.com/ipfs/go-ipfs/metrics"
17
eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog"
17
- debugerror "github.com/ipfs/go-ipfs/util/debugerror"
18
19
diag "github.com/ipfs/go-ipfs/diagnostics"
20
ic "github.com/ipfs/go-ipfs/p2p/crypto"
@@ -133,7 +133,7 @@ func NewIPFSNode(parent context.Context, option ConfigOption) (*IpfsNode, error)
133
134
node.Blocks, err = bserv.New(node.Blockstore, node.Exchange)
135
if err != nil {
136
- return nil, debugerror.Wrap(err)
136
+ return nil, err
137
}
138
if node.Peerstore == nil {
139
node.Peerstore = peer.NewPeerstore()
@@ -149,7 +149,7 @@ func NewIPFSNode(parent context.Context, option ConfigOption) (*IpfsNode, error)
149
if node.OnlineMode() {
150
fs, err := ipnsfs.NewFilesystem(ctx, node.DAG, node.Namesys, node.Pinning, node.PrivateKey)
151
if err != nil && err != kb.ErrLookupFailure {
152
- return nil, debugerror.Wrap(err)
152
+ return nil, err
153
}
154
node.IpnsFs = fs
155
}
@@ -192,7 +192,7 @@ func standardWithRouting(r repo.Repo, online bool, routingOption RoutingOption,
192
// to test all node construction code paths.
193
194
if r == nil {
195
- return nil, debugerror.Errorf("repo required")
195
+ return nil, fmt.Errorf("repo required")
196
}
197
n = &IpfsNode{
198
mode: func() mode {
@@ -214,7 +214,7 @@ func standardWithRouting(r repo.Repo, online bool, routingOption RoutingOption,
214
215
n.Blockstore, err = bstore.WriteCached(bstore.NewBlockstore(n.Repo.Datastore()), kSizeBlockstoreWriteCache)
216
if err != nil {
217
- return nil, debugerror.Wrap(err)
217
+ return nil, err
218
}
219
220
if online {
@@ -233,7 +233,7 @@ func standardWithRouting(r repo.Repo, online bool, routingOption RoutingOption,
233
func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption RoutingOption, hostOption HostOption) error {
234
235
if n.PeerHost != nil { // already online.
236
- return debugerror.New("node already online")
236
+ return errors.New("node already online")
237
}
238
239
// load private key
@@ -246,7 +246,7 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
246
247
peerhost, err := hostOption(ctx, n.Identity, n.Peerstore, n.Reporter)
248
if err != nil {
249
- return debugerror.Wrap(err)
249
+ return err
250
}
251
252
if err := n.startOnlineServicesWithHost(ctx, peerhost, routingOption); err != nil {
@@ -255,7 +255,7 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
255
256
// Ok, now we're ready to listen.
257
if err := startListening(ctx, n.PeerHost, n.Repo.Config()); err != nil {
258
- return debugerror.Wrap(err)
258
+ return err
259
}
260
261
n.Reprovider = rp.NewReprovider(n.Routing, n.Blockstore)
@@ -273,7 +273,7 @@ func (n *IpfsNode) startOnlineServicesWithHost(ctx context.Context, host p2phost
273
// setup routing service
274
r, err := routingOption(ctx, host, n.Repo.Datastore())
275
if err != nil {
276
- return debugerror.Wrap(err)
276
+ return err
277
}
278
n.Routing = r
279
@@ -380,15 +380,15 @@ func (n *IpfsNode) Bootstrap(cfg BootstrapConfig) error {
380
381
func (n *IpfsNode) loadID() error {
382
if n.Identity != "" {
383
- return debugerror.New("identity already loaded")
383
+ return errors.New("identity already loaded")
384
}
385
386
cid := n.Repo.Config().Identity.PeerID
387
if cid == "" {
388
- return debugerror.New("Identity was not set in config (was ipfs init run?)")
388
+ return errors.New("Identity was not set in config (was ipfs init run?)")
389
}
390
if len(cid) == 0 {
391
- return debugerror.New("No peer ID in config! (was ipfs init run?)")
391
+ return errors.New("No peer ID in config! (was ipfs init run?)")
392
}
393
394
n.Identity = peer.ID(b58.Decode(cid))
@@ -397,11 +397,11 @@ func (n *IpfsNode) loadID() error {
397
398
func (n *IpfsNode) LoadPrivateKey() error {
399
if n.Identity == "" || n.Peerstore == nil {
400
- return debugerror.New("loaded private key out of order.")
400
+ return errors.New("loaded private key out of order.")
401
}
402
403
if n.PrivateKey != nil {
404
- return debugerror.New("private key already loaded")
404
+ return errors.New("private key already loaded")
405
}
406
407
sk, err := loadPrivateKey(&n.Repo.Config().Identity, n.Identity)
@@ -480,7 +480,7 @@ func constructPeerHost(ctx context.Context, id peer.ID, ps peer.Peerstore, bwr m
480
// no addresses to begin with. we'll start later.
481
network, err := swarm.NewNetwork(ctx, nil, id, ps, bwr)
482
if err != nil {
483
- return nil, debugerror.Wrap(err)
483
+ return nil, err
484
}
485
486
host := p2pbhost.New(network, p2pbhost.NATPortMap, bwr)
@@ -492,7 +492,7 @@ func constructPeerHost(ctx context.Context, id peer.ID, ps peer.Peerstore, bwr m
492
func startListening(ctx context.Context, host p2phost.Host, cfg *config.Config) error {
493
listenAddrs, err := listenAddresses(cfg)
494
if err != nil {
495
- return debugerror.Wrap(err)
495
+ return err
496
}
497
498
// make sure we error out if our config does not have addresses we can use
@@ -500,7 +500,7 @@ func startListening(ctx context.Context, host p2phost.Host, cfg *config.Config)
500
filteredAddrs := addrutil.FilterUsableAddrs(listenAddrs)
501
log.Debugf("Config.Addresses.Swarm:%s (filtered)", filteredAddrs)
502
if len(filteredAddrs) < 1 {
503
- return debugerror.Errorf("addresses in config not usable: %s", listenAddrs)
503
+ return fmt.Errorf("addresses in config not usable: %s", listenAddrs)
504
}
505
506
// Actually start listening:
@@ -511,7 +511,7 @@ func startListening(ctx context.Context, host p2phost.Host, cfg *config.Config)
511
// list out our addresses
512
addrs, err := host.Network().InterfaceListenAddresses()
513
if err != nil {
514
- return debugerror.Wrap(err)
514
+ return err
515
}
516
log.Infof("Swarm listening at: %s", addrs)
517
return nil
exchange/bitswap/bitswap.go
+2
-2
@@ -3,6 +3,7 @@
3
package bitswap
4
5
import (
6
+ "errors"
7
"math"
8
"sync"
9
"time"
@@ -21,7 +22,6 @@ import (
22
"github.com/ipfs/go-ipfs/thirdparty/delay"
23
eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog"
24
u "github.com/ipfs/go-ipfs/util"
24
- errors "github.com/ipfs/go-ipfs/util/debugerror"
25
pset "github.com/ipfs/go-ipfs/util/peerset" // TODO move this to peerstore
26
)
27
@@ -432,7 +432,7 @@ func (bs *Bitswap) ReceiveError(err error) {
432
func (bs *Bitswap) send(ctx context.Context, p peer.ID, m bsmsg.BitSwapMessage) error {
433
defer log.EventBegin(ctx, "sendMessage", p, m).Done()
434
if err := bs.network.SendMessage(ctx, p, m); err != nil {
435
- return errors.Wrap(err)
435
+ return err
436
}
437
return bs.engine.MessageSent(p, m)
438
}
exchange/reprovide/reprovide.go
+2
-2
@@ -1,6 +1,7 @@
1
package reprovide
2
3
import (
4
+ "fmt"
5
"time"
6
7
backoff "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/cenkalti/backoff"
@@ -8,7 +9,6 @@ import (
9
blocks "github.com/ipfs/go-ipfs/blocks/blockstore"
10
routing "github.com/ipfs/go-ipfs/routing"
11
eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog"
11
- debugerror "github.com/ipfs/go-ipfs/util/debugerror"
12
)
13
14
var log = eventlog.Logger("reprovider")
@@ -50,7 +50,7 @@ func (rp *Reprovider) ProvideEvery(ctx context.Context, tick time.Duration) {
50
func (rp *Reprovider) Reprovide(ctx context.Context) error {
51
keychan, err := rp.bstore.AllKeysChan(ctx)
52
if err != nil {
53
- return debugerror.Errorf("Failed to get key chan from blockstore: %s", err)
53
+ return fmt.Errorf("Failed to get key chan from blockstore: %s", err)
54
}
55
for k := range keychan {
56
op := func() error {
p2p/net/conn/dial.go
+1
-2
@@ -15,7 +15,6 @@ import (
15
16
addrutil "github.com/ipfs/go-ipfs/p2p/net/swarm/addr"
17
peer "github.com/ipfs/go-ipfs/p2p/peer"
18
- debugerror "github.com/ipfs/go-ipfs/util/debugerror"
18
)
19
20
// String returns the string rep of d.
@@ -107,7 +106,7 @@ func (d *Dialer) rawConnDial(ctx context.Context, raddr ma.Multiaddr, remote pee
106
107
if strings.HasPrefix(raddr.String(), "/ip4/0.0.0.0") {
108
log.Event(ctx, "connDialZeroAddr", lgbl.Dial("conn", d.LocalPeer, remote, nil, raddr))
110
- return nil, debugerror.Errorf("Attempted to connect to zero address: %s", raddr)
109
+ return nil, fmt.Errorf("Attempted to connect to zero address: %s", raddr)
110
}
111
112
// get local addr to use.
p2p/net/conn/secure_conn.go
+1
-1
@@ -1,6 +1,7 @@
1
package conn
2
3
import (
4
+ "errors"
5
"net"
6
"time"
7
@@ -11,7 +12,6 @@ import (
12
ic "github.com/ipfs/go-ipfs/p2p/crypto"
13
secio "github.com/ipfs/go-ipfs/p2p/crypto/secio"
14
peer "github.com/ipfs/go-ipfs/p2p/peer"
14
- errors "github.com/ipfs/go-ipfs/util/debugerror"
15
)
16
17
// secureConn wraps another Conn object with an encrypted channel.
p2p/net/swarm/swarm_test.go
+5
-5
@@ -2,6 +2,7 @@ package swarm
2
3
import (
4
"bytes"
5
+ "fmt"
6
"io"
7
"sync"
8
"testing"
@@ -10,7 +11,6 @@ import (
11
metrics "github.com/ipfs/go-ipfs/metrics"
12
inet "github.com/ipfs/go-ipfs/p2p/net"
13
peer "github.com/ipfs/go-ipfs/p2p/peer"
13
- errors "github.com/ipfs/go-ipfs/util/debugerror"
14
testutil "github.com/ipfs/go-ipfs/util/testutil"
15
16
ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
@@ -130,7 +130,7 @@ func SubtestSwarm(t *testing.T, SwarmNum int, MsgNum int) {
130
// first, one stream per peer (nice)
131
stream, err := s1.NewStreamWithPeer(p)
132
if err != nil {
133
- errChan <- errors.Wrap(err)
133
+ errChan <- err
134
return
135
}
136
@@ -177,12 +177,12 @@ func SubtestSwarm(t *testing.T, SwarmNum int, MsgNum int) {
177
178
// read from the stream
179
if _, err := stream.Read(msg); err != nil {
180
- errChan <- errors.Wrap(err)
180
+ errChan <- err
181
continue
182
}
183
184
if string(msg) != "pong" {
185
- errChan <- errors.Errorf("unexpected message: %s", msg)
185
+ errChan <- fmt.Errorf("unexpected message: %s", msg)
186
continue
187
}
188
@@ -195,7 +195,7 @@ func SubtestSwarm(t *testing.T, SwarmNum int, MsgNum int) {
195
}
196
197
if count != countShouldBe {
198
- errChan <- errors.Errorf("count mismatch: %d != %d", count, countShouldBe)
198
+ errChan <- fmt.Errorf("count mismatch: %d != %d", count, countShouldBe)
199
}
200
}()
201
repo/config/bootstrap_peers.go
+3
-2
@@ -1,7 +1,8 @@
1
package config
2
3
import (
4
- errors "github.com/ipfs/go-ipfs/util/debugerror"
4
+ "errors"
5
+ "fmt"
6
7
iaddr "github.com/ipfs/go-ipfs/util/ipfsaddr"
8
)
@@ -40,7 +41,7 @@ func (c *Config) BootstrapPeers() ([]BootstrapPeer, error) {
41
func DefaultBootstrapPeers() ([]BootstrapPeer, error) {
42
ps, err := ParseBootstrapPeers(DefaultBootstrapAddresses)
43
if err != nil {
43
- return nil, errors.Errorf(`failed to parse hardcoded bootstrap peers: %s
44
+ return nil, fmt.Errorf(`failed to parse hardcoded bootstrap peers: %s
45
This is a problem with the ipfs codebase. Please report it to the dev team.`, err)
46
}
47
return ps, nil
repo/config/gateway.go
+1
-1
@@ -3,5 +3,5 @@ package config
3
// Gateway contains options for the HTTP gateway server.
4
type Gateway struct {
5
RootRedirect string
6
- Writable bool
6
+ Writable bool
7
}
repo/config/init.go
+5
-5
@@ -2,12 +2,12 @@ package config
2
3
import (
4
"encoding/base64"
5
+ "errors"
6
"fmt"
7
"io"
8
9
ci "github.com/ipfs/go-ipfs/p2p/crypto"
10
peer "github.com/ipfs/go-ipfs/p2p/peer"
10
- errors "github.com/ipfs/go-ipfs/util/debugerror"
11
)
12
13
func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
@@ -44,10 +44,10 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
44
Gateway: "/ip4/127.0.0.1/tcp/8080",
45
},
46
47
- Bootstrap: BootstrapPeerStrings(bootstrapPeers),
48
- SupernodeRouting: *snr,
49
- Datastore: *ds,
50
- Identity: identity,
47
+ Bootstrap: BootstrapPeerStrings(bootstrapPeers),
48
+ SupernodeRouting: *snr,
49
+ Datastore: *ds,
50
+ Identity: identity,
51
Log: Log{
52
MaxSizeMB: 250,
53
MaxBackups: 1,
repo/config/log.go
-1
@@ -1,6 +1,5 @@
1
package config
2
3
-
3
type Log struct {
4
MaxSizeMB int
5
MaxBackups int
repo/fsrepo/fsrepo.go
+8
-7
@@ -1,6 +1,8 @@
1
package fsrepo
2
3
import (
4
+ "errors"
5
+ "fmt"
6
"io"
7
"os"
8
"path"
@@ -20,7 +22,6 @@ import (
22
u "github.com/ipfs/go-ipfs/util"
23
util "github.com/ipfs/go-ipfs/util"
24
ds2 "github.com/ipfs/go-ipfs/util/datastore2"
23
- debugerror "github.com/ipfs/go-ipfs/util/debugerror"
25
)
26
27
const (
@@ -100,7 +101,7 @@ func open(repoPath string) (repo.Repo, error) {
101
}()
102
103
if !isInitializedUnsynced(r.path) {
103
- return nil, debugerror.New("ipfs not initialized, please run 'ipfs init'")
104
+ return nil, errors.New("ipfs not initialized, please run 'ipfs init'")
105
}
106
// check repo path, then check all constituent parts.
107
// TODO acquire repo lock
@@ -191,7 +192,7 @@ func Init(repoPath string, conf *config.Config) error {
192
// During Init, we merely check that the directory is writeable.
193
p := path.Join(repoPath, defaultDataStoreDirectory)
194
if err := dir.Writable(p); err != nil {
194
- return debugerror.Errorf("datastore: %s", err)
195
+ return fmt.Errorf("datastore: %s", err)
196
}
197
198
if err := dir.Writable(path.Join(repoPath, "logs")); err != nil {
@@ -240,7 +241,7 @@ func (r *FSRepo) openDatastore() error {
241
Compression: ldbopts.NoCompression,
242
})
243
if err != nil {
243
- return debugerror.New("unable to open leveldb datastore")
244
+ return errors.New("unable to open leveldb datastore")
245
}
246
r.ds = ds
247
return nil
@@ -264,7 +265,7 @@ func (r *FSRepo) Close() error {
265
defer packageLock.Unlock()
266
267
if r.closed {
267
- return debugerror.New("repo is closed")
268
+ return errors.New("repo is closed")
269
}
270
271
if err := r.ds.Close(); err != nil {
@@ -349,7 +350,7 @@ func (r *FSRepo) GetConfigKey(key string) (interface{}, error) {
350
defer packageLock.Unlock()
351
352
if r.closed {
352
- return nil, debugerror.New("repo is closed")
353
+ return nil, errors.New("repo is closed")
354
}
355
356
filename, err := config.Filename(r.path)
@@ -369,7 +370,7 @@ func (r *FSRepo) SetConfigKey(key string, value interface{}) error {
370
defer packageLock.Unlock()
371
372
if r.closed {
372
- return debugerror.New("repo is closed")
373
+ return errors.New("repo is closed")
374
}
375
376
filename, err := config.Filename(r.path)
repo/fsrepo/lock/lock.go
+1
-2
@@ -6,7 +6,6 @@ import (
6
7
lock "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/camlistore/lock"
8
"github.com/ipfs/go-ipfs/util"
9
- "github.com/ipfs/go-ipfs/util/debugerror"
9
)
10
11
// LockFile is the filename of the daemon lock, relative to config dir
@@ -15,7 +14,7 @@ const LockFile = "daemon.lock"
14
15
func Lock(confdir string) (io.Closer, error) {
16
c, err := lock.Lock(path.Join(confdir, LockFile))
18
- return c, debugerror.Wrap(err)
17
+ return c, err
18
}
19
20
func Locked(confdir string) bool {
repo/fsrepo/serialize/serialize.go
+2
-2
@@ -2,6 +2,7 @@ package fsrepo
2
3
import (
4
"encoding/json"
5
+ "errors"
6
"fmt"
7
"io"
8
"os"
@@ -10,7 +11,6 @@ import (
11
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/facebookgo/atomicfile"
12
"github.com/ipfs/go-ipfs/repo/config"
13
"github.com/ipfs/go-ipfs/util"
13
- "github.com/ipfs/go-ipfs/util/debugerror"
14
)
15
16
var log = util.Logger("fsrepo")
@@ -59,7 +59,7 @@ func encode(w io.Writer, value interface{}) error {
59
func Load(filename string) (*config.Config, error) {
60
// if nothing is there, fail. User must run 'ipfs init'
61
if !util.FileExists(filename) {
62
- return nil, debugerror.New("ipfs not initialized, please run 'ipfs init'")
62
+ return nil, errors.New("ipfs not initialized, please run 'ipfs init'")
63
}
64
65
var cfg config.Config
routing/dht/routing.go
+3
-4
@@ -13,7 +13,6 @@ import (
13
kb "github.com/ipfs/go-ipfs/routing/kbucket"
14
record "github.com/ipfs/go-ipfs/routing/record"
15
u "github.com/ipfs/go-ipfs/util"
16
- errors "github.com/ipfs/go-ipfs/util/debugerror"
16
pset "github.com/ipfs/go-ipfs/util/peerset"
17
)
18
@@ -95,7 +94,7 @@ func (dht *IpfsDHT) GetValue(ctx context.Context, key u.Key) ([]byte, error) {
94
log.Debugf("peers in rt: %s", len(rtp), rtp)
95
if len(rtp) == 0 {
96
log.Warning("No peers from routing table!")
98
- return nil, errors.Wrap(kb.ErrLookupFailure)
97
+ return nil, kb.ErrLookupFailure
98
}
99
100
// setup the Query
@@ -278,7 +277,7 @@ func (dht *IpfsDHT) FindPeer(ctx context.Context, id peer.ID) (peer.PeerInfo, er
277
278
peers := dht.routingTable.NearestPeers(kb.ConvertPeerID(id), AlphaValue)
279
if len(peers) == 0 {
281
- return peer.PeerInfo{}, errors.Wrap(kb.ErrLookupFailure)
280
+ return peer.PeerInfo{}, kb.ErrLookupFailure
281
}
282
283
// Sanity...
@@ -344,7 +343,7 @@ func (dht *IpfsDHT) FindPeersConnectedToPeer(ctx context.Context, id peer.ID) (<
343
344
peers := dht.routingTable.NearestPeers(kb.ConvertPeerID(id), AlphaValue)
345
if len(peers) == 0 {
347
- return nil, errors.Wrap(kb.ErrLookupFailure)
346
+ return nil, kb.ErrLookupFailure
347
}
348
349
// setup the Query
routing/mock/dht.go
-1
@@ -30,7 +30,6 @@ func (rs *mocknetserver) ClientWithDatastore(ctx context.Context, p testutil.Ide
30
host, err := rs.mn.AddPeer(p.PrivateKey(), p.Address())
31
if err != nil {
32
panic("FIXME")
33
- // return nil, debugerror.Wrap(err)
33
}
34
return dht.NewDHT(ctx, host, sync.MutexWrap(ds))
35
}
routing/supernode/client.go
+5
-5
@@ -2,6 +2,7 @@ package supernode
2
3
import (
4
"bytes"
5
+ "errors"
6
"time"
7
8
proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
@@ -13,7 +14,6 @@ import (
14
proxy "github.com/ipfs/go-ipfs/routing/supernode/proxy"
15
eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog"
16
u "github.com/ipfs/go-ipfs/util"
16
- errors "github.com/ipfs/go-ipfs/util/debugerror"
17
)
18
19
var log = eventlog.Logger("supernode")
@@ -44,13 +44,13 @@ func (c *Client) FindProvidersAsync(ctx context.Context, k u.Key, max int) <-cha
44
request := pb.NewMessage(pb.Message_GET_PROVIDERS, string(k), 0)
45
response, err := c.proxy.SendRequest(ctx, request)
46
if err != nil {
47
- log.Debug(errors.Wrap(err))
47
+ log.Debug(err)
48
return
49
}
50
for _, p := range pb.PBPeersToPeerInfos(response.GetProviderPeers()) {
51
select {
52
case <-ctx.Done():
53
- log.Debug(errors.Wrap(ctx.Err()))
53
+ log.Debug(ctx.Err())
54
return
55
case ch <- p:
56
}
@@ -75,7 +75,7 @@ func (c *Client) GetValue(ctx context.Context, k u.Key) ([]byte, error) {
75
msg := pb.NewMessage(pb.Message_GET_VALUE, string(k), 0)
76
response, err := c.proxy.SendRequest(ctx, msg) // TODO wrap to hide the remote
77
if err != nil {
78
- return nil, errors.Wrap(err)
78
+ return nil, err
79
}
80
return response.Record.GetValue(), nil
81
}
@@ -101,7 +101,7 @@ func (c *Client) FindPeer(ctx context.Context, id peer.ID) (peer.PeerInfo, error
101
request := pb.NewMessage(pb.Message_FIND_NODE, string(id), 0)
102
response, err := c.proxy.SendRequest(ctx, request) // hide remote
103
if err != nil {
104
- return peer.PeerInfo{}, errors.Wrap(err)
104
+ return peer.PeerInfo{}, err
105
}
106
for _, p := range pb.PBPeersToPeerInfos(response.GetCloserPeers()) {
107
if p.ID == id {
routing/supernode/proxy/loopback.go
+1
-2
@@ -6,7 +6,6 @@ import (
6
inet "github.com/ipfs/go-ipfs/p2p/net"
7
peer "github.com/ipfs/go-ipfs/p2p/peer"
8
dhtpb "github.com/ipfs/go-ipfs/routing/dht/pb"
9
- errors "github.com/ipfs/go-ipfs/util/debugerror"
9
)
10
11
// RequestHandler handles routing requests locally
@@ -43,7 +42,7 @@ func (lb *Loopback) HandleStream(s inet.Stream) {
42
pbr := ggio.NewDelimitedReader(s, inet.MessageSizeMax)
43
var incoming dhtpb.Message
44
if err := pbr.ReadMsg(&incoming); err != nil {
46
- log.Debug(errors.Wrap(err))
45
+ log.Debug(err)
46
return
47
}
48
ctx := context.TODO()
routing/supernode/proxy/standard.go
+3
-2
@@ -1,6 +1,8 @@
1
package proxy
2
3
import (
4
+ "errors"
5
+
6
ggio "github.com/ipfs/go-ipfs/Godeps/_workspace/src/code.google.com/p/gogoprotobuf/io"
7
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
8
host "github.com/ipfs/go-ipfs/p2p/host"
@@ -10,7 +12,6 @@ import (
12
kbucket "github.com/ipfs/go-ipfs/routing/kbucket"
13
eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog"
14
"github.com/ipfs/go-ipfs/util"
13
- errors "github.com/ipfs/go-ipfs/util/debugerror"
15
)
16
17
const ProtocolSNR = "/ipfs/supernoderouting"
@@ -103,7 +104,7 @@ func (px *standard) sendMessage(ctx context.Context, m *dhtpb.Message, remote pe
104
defer s.Close()
105
pbw := ggio.NewDelimitedWriter(s)
106
if err := pbw.WriteMsg(m); err != nil {
106
- return errors.Wrap(err)
107
+ return err
108
}
109
return nil
110
}
routing/supernode/server.go
+2
-2
@@ -1,6 +1,7 @@
1
package supernode
2
3
import (
4
+ "errors"
5
"fmt"
6
7
proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
@@ -11,7 +12,6 @@ import (
12
record "github.com/ipfs/go-ipfs/routing/record"
13
proxy "github.com/ipfs/go-ipfs/routing/supernode/proxy"
14
util "github.com/ipfs/go-ipfs/util"
14
- errors "github.com/ipfs/go-ipfs/util/debugerror"
15
)
16
17
// Server handles routing queries using a database backend
@@ -117,7 +117,7 @@ func getRoutingRecord(ds datastore.Datastore, k util.Key) (*dhtpb.Record, error)
117
dskey := k.DsKey()
118
val, err := ds.Get(dskey)
119
if err != nil {
120
- return nil, errors.Wrap(err)
120
+ return nil, err
121
}
122
recordBytes, ok := val.([]byte)
123
if !ok {