improve errors a bit
This commit is contained in:
parent
6bc21a124f
commit
2facece1f6
@ -9,6 +9,7 @@ import (
|
||||
|
||||
logging "github.com/ipfs/go-log"
|
||||
manet "github.com/multiformats/go-multiaddr-net"
|
||||
"github.com/pkg/errors"
|
||||
"gopkg.in/urfave/cli.v2"
|
||||
|
||||
"github.com/filecoin-project/go-lotus/api"
|
||||
@ -33,7 +34,7 @@ func GetAPI(ctx *cli.Context) (api.FullNode, error) {
|
||||
|
||||
ma, err := r.APIEndpoint()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "failed to get api endpoint")
|
||||
}
|
||||
_, addr, err := manet.DialArgs(ma)
|
||||
if err != nil {
|
||||
|
@ -104,8 +104,8 @@ func (fsr *FsRepo) initKeystore() error {
|
||||
// APIEndpoint returns endpoint of API in this repo
|
||||
func (fsr *FsRepo) APIEndpoint() (multiaddr.Multiaddr, error) {
|
||||
p := filepath.Join(fsr.path, fsAPI)
|
||||
f, err := os.Open(p)
|
||||
|
||||
f, err := os.Open(p)
|
||||
if os.IsNotExist(err) {
|
||||
return nil, ErrNoAPIEndpoint
|
||||
} else if err != nil {
|
||||
@ -115,7 +115,7 @@ func (fsr *FsRepo) APIEndpoint() (multiaddr.Multiaddr, error) {
|
||||
|
||||
data, err := ioutil.ReadAll(f)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrapf(err, "failed to read %q", p)
|
||||
}
|
||||
strma := string(data)
|
||||
strma = strings.TrimSpace(strma)
|
||||
|
Loading…
Reference in New Issue
Block a user