Commit ef65bb1c authored by Brian Tiger Chow's avatar Brian Tiger Chow Committed by Juan Batiz-Benet

revert to debug error

@jbenet

License: MIT
Signed-off-by: default avatarBrian Tiger Chow <brian@perfmode.com>
parent bc396610
......@@ -13,7 +13,7 @@ import (
commands "github.com/jbenet/go-ipfs/core/commands2"
daemon "github.com/jbenet/go-ipfs/daemon2"
util "github.com/jbenet/go-ipfs/util"
errors "github.com/jbenet/go-ipfs/util/errors"
"github.com/jbenet/go-ipfs/util/debugerror"
)
const (
......@@ -54,14 +54,14 @@ func daemonFunc(req cmds.Request) (interface{}, error) {
if !util.FileExists(req.Context().ConfigRoot) {
err := initWithDefaults(req.Context().ConfigRoot)
if err != nil {
return nil, errors.Wrap(err)
return nil, debugerror.Wrap(err)
}
}
}
lock, err := daemon.Lock(req.Context().ConfigRoot)
if err != nil {
return nil, errors.Errorf("Couldn't obtain lock. Is another daemon already running?")
return nil, debugerror.Errorf("Couldn't obtain lock. Is another daemon already running?")
}
defer lock.Close()
......
......@@ -16,7 +16,7 @@ import (
chunk "github.com/jbenet/go-ipfs/importer/chunk"
peer "github.com/jbenet/go-ipfs/peer"
u "github.com/jbenet/go-ipfs/util"
errors "github.com/jbenet/go-ipfs/util/errors"
"github.com/jbenet/go-ipfs/util/debugerror"
)
const nBitsForKeypairDefault = 4096
......@@ -62,7 +62,7 @@ var initCmd = &cmds.Command{
},
}
var errCannotInitConfigExists = errors.New(`ipfs configuration file already exists!
var errCannotInitConfigExists = debugerror.New(`ipfs configuration file already exists!
Reinitializing would overwrite your keys.
(use -f to force overwrite)
`)
......@@ -84,7 +84,7 @@ For a short demo of what you can do, enter 'ipfs tour'
func initWithDefaults(configRoot string) error {
_, err := doInit(configRoot, "", false, nBitsForKeypairDefault)
return errors.Wrap(err)
return debugerror.Wrap(err)
}
func doInit(configRoot string, dspathOverride string, force bool, nBitsForKeypair int) (interface{}, error) {
......@@ -93,7 +93,7 @@ func doInit(configRoot string, dspathOverride string, force bool, nBitsForKeypai
configFilename, err := config.Filename(configRoot)
if err != nil {
return nil, errors.New("Couldn't get home directory path")
return nil, debugerror.New("Couldn't get home directory path")
}
if u.FileExists(configFilename) && !force {
......@@ -155,7 +155,7 @@ func datastoreConfig(dspath string) (config.Datastore, error) {
err := initCheckDir(dspath)
if err != nil {
return ds, errors.Errorf("datastore: %s", err)
return ds, debugerror.Errorf("datastore: %s", err)
}
return ds, nil
......@@ -229,7 +229,7 @@ func identityConfig(nbits int, onBegin func(), onSuccess func(config.Identity))
// TODO guard higher up
ident := config.Identity{}
if nbits < 1024 {
return ident, errors.New("Bitsize less than 1024 is considered unsafe.")
return ident, debugerror.New("Bitsize less than 1024 is considered unsafe.")
}
onBegin()
......@@ -260,13 +260,13 @@ func initLogs(logpath string) (config.Logs, error) {
var err error
logpath, err = config.LogsPath("")
if err != nil {
return config.Logs{}, errors.Wrap(err)
return config.Logs{}, debugerror.Wrap(err)
}
}
err := initCheckDir(logpath)
if err != nil {
return config.Logs{}, errors.Errorf("logs: %s", err)
return config.Logs{}, debugerror.Errorf("logs: %s", err)
}
return config.Logs{
......@@ -285,7 +285,7 @@ func initCheckDir(path string) error {
if f, err := os.Create(filepath.Join(path, "._check_writeable")); err == nil {
os.Remove(f.Name())
} else {
return errors.New("'" + path + "' is not writeable")
return debugerror.New("'" + path + "' is not writeable")
}
return nil
}
package main
import (
"errors"
"fmt"
"io"
"os"
......@@ -21,7 +22,7 @@ import (
daemon "github.com/jbenet/go-ipfs/daemon2"
updates "github.com/jbenet/go-ipfs/updates"
u "github.com/jbenet/go-ipfs/util"
errors "github.com/jbenet/go-ipfs/util/errors"
"github.com/jbenet/go-ipfs/util/debugerror"
eventlog "github.com/jbenet/go-ipfs/util/eventlog"
)
......@@ -331,7 +332,7 @@ func commandDetails(path []string, root *cmds.Command) (*cmdDetails, error) {
var found bool
cmd, found = cmd.Subcommands[cmp]
if !found {
return nil, errors.Errorf("subcommand %s should be in root", cmp)
return nil, debugerror.Errorf("subcommand %s should be in root", cmp)
}
if cmdDetails, found := cmdDetailsMap[cmd]; found {
......
......@@ -9,7 +9,7 @@ import (
"path/filepath"
u "github.com/jbenet/go-ipfs/util"
errors "github.com/jbenet/go-ipfs/util/errors"
"github.com/jbenet/go-ipfs/util/debugerror"
)
var log = u.Logger("config")
......@@ -147,7 +147,7 @@ func (i *Identity) DecodePrivateKey(passphrase string) (crypto.PrivateKey, error
func Load(filename string) (*Config, error) {
// if nothing is there, fail. User must run 'ipfs init'
if _, err := os.Stat(filename); os.IsNotExist(err) {
return nil, errors.New("ipfs not initialized, please run 'ipfs init'")
return nil, debugerror.New("ipfs not initialized, please run 'ipfs init'")
}
var cfg Config
......
......@@ -27,7 +27,7 @@ import (
dht "github.com/jbenet/go-ipfs/routing/dht"
u "github.com/jbenet/go-ipfs/util"
ctxc "github.com/jbenet/go-ipfs/util/ctxcloser"
"github.com/jbenet/go-ipfs/util/errors"
"github.com/jbenet/go-ipfs/util/debugerror"
)
const IpnsValidatorTag = "ipns"
......@@ -102,7 +102,7 @@ func NewIpfsNode(cfg *config.Config, online bool) (n *IpfsNode, err error) {
}()
if cfg == nil {
return nil, errors.Errorf("configuration required")
return nil, debugerror.Errorf("configuration required")
}
// derive this from a higher context.
......@@ -115,14 +115,14 @@ func NewIpfsNode(cfg *config.Config, online bool) (n *IpfsNode, err error) {
// setup datastore.
if n.Datastore, err = makeDatastore(cfg.Datastore); err != nil {
return nil, errors.Wrap(err)
return nil, debugerror.Wrap(err)
}
// setup peerstore + local peer identity
n.Peerstore = peer.NewPeerstore()
n.Identity, err = initIdentity(&n.Config.Identity, n.Peerstore, online)
if err != nil {
return nil, errors.Wrap(err)
return nil, debugerror.Wrap(err)
}
// setup online services
......@@ -142,12 +142,12 @@ func NewIpfsNode(cfg *config.Config, online bool) (n *IpfsNode, err error) {
// setup the network
listenAddrs, err := listenAddresses(cfg)
if err != nil {
return nil, errors.Wrap(err)
return nil, debugerror.Wrap(err)
}
n.Network, err = inet.NewIpfsNetwork(ctx, listenAddrs, n.Identity, n.Peerstore, muxMap)
if err != nil {
return nil, errors.Wrap(err)
return nil, debugerror.Wrap(err)
}
n.AddCloserChild(n.Network)
......@@ -176,7 +176,7 @@ func NewIpfsNode(cfg *config.Config, online bool) (n *IpfsNode, err error) {
// session that simply doesn't return blocks
n.Blocks, err = bserv.NewBlockService(n.Datastore, n.Exchange)
if err != nil {
return nil, errors.Wrap(err)
return nil, debugerror.Wrap(err)
}
n.DAG = merkledag.NewDAGService(n.Blocks)
......@@ -202,11 +202,11 @@ func (n *IpfsNode) OnlineMode() bool {
func initIdentity(cfg *config.Identity, peers peer.Peerstore, online bool) (peer.Peer, error) {
if cfg.PeerID == "" {
return nil, errors.New("Identity was not set in config (was ipfs init run?)")
return nil, debugerror.New("Identity was not set in config (was ipfs init run?)")
}
if len(cfg.PeerID) == 0 {
return nil, errors.New("No peer ID in config! (was ipfs init run?)")
return nil, debugerror.New("No peer ID in config! (was ipfs init run?)")
}
// get peer from peerstore (so it is constructed there)
......
......@@ -10,12 +10,12 @@ import (
config "github.com/jbenet/go-ipfs/config"
u "github.com/jbenet/go-ipfs/util"
"github.com/jbenet/go-ipfs/util/errors"
"github.com/jbenet/go-ipfs/util/debugerror"
)
func makeDatastore(cfg config.Datastore) (u.ThreadSafeDatastoreCloser, error) {
if len(cfg.Type) == 0 {
return nil, errors.Errorf("config datastore.type required")
return nil, debugerror.Errorf("config datastore.type required")
}
switch cfg.Type {
......@@ -35,17 +35,17 @@ func makeDatastore(cfg config.Datastore) (u.ThreadSafeDatastoreCloser, error) {
return u.CloserWrap(syncds.MutexWrap(ktd)), nil
}
return nil, errors.Errorf("Unknown datastore type: %s", cfg.Type)
return nil, debugerror.Errorf("Unknown datastore type: %s", cfg.Type)
}
func makeLevelDBDatastore(cfg config.Datastore) (u.ThreadSafeDatastoreCloser, error) {
if len(cfg.Path) == 0 {
return nil, errors.Errorf("config datastore.path required for leveldb")
return nil, debugerror.Errorf("config datastore.path required for leveldb")
}
ds, err := lds.NewDatastore(cfg.Path, &lds.Options{
// TODO don't import ldbopts. Get from go-datastore.leveldb
Compression: ldbopts.NoCompression,
})
return ds, errors.Wrap(err)
return ds, debugerror.Wrap(err)
}
......@@ -6,7 +6,7 @@ import (
lock "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/camlistore/lock"
"github.com/jbenet/go-ipfs/util"
"github.com/jbenet/go-ipfs/util/errors"
"github.com/jbenet/go-ipfs/util/debugerror"
)
// LockFile is the filename of the daemon lock, relative to config dir
......@@ -14,7 +14,7 @@ const LockFile = "daemon.lock"
func Lock(confdir string) (io.Closer, error) {
c, err := lock.Lock(path.Join(confdir, LockFile))
return c, errors.Wrap(err)
return c, debugerror.Wrap(err)
}
func Locked(confdir string) bool {
......
// package errors provides ways to augment errors with additional
// package debugerror provides ways to augment errors with additional
// information to allow for easier debugging.
package errors
package debugerror
import (
"errors"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment