From 586bd7f053bcdde94be71c725a098875bd4af4c9 Mon Sep 17 00:00:00 2001 From: shawn Date: Wed, 26 Oct 2022 18:29:38 +0800 Subject: [PATCH] feat: update error log --- cmd/btfs/daemon.go | 16 +++++++++++++++- cmd/btfs/init.go | 3 +++ reportstatus/reportstatus.go | 10 ++++++++++ settlement/swap/vault/factory.go | 8 ++++++-- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/cmd/btfs/daemon.go b/cmd/btfs/daemon.go index 8f64c34e1..633925eac 100644 --- a/cmd/btfs/daemon.go +++ b/cmd/btfs/daemon.go @@ -332,6 +332,12 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment repo, err := fsrepo.Open(cctx.ConfigRoot) switch err { default: + if strings.Contains(err.Error(), "someone else has the lock") { + fmt.Println(`Error:Someone else has the lock; +What causes this error: there is already one daemon process running in background +Solution: kill it first and run btfs daemon again. +If the user need to start multiple nodes on the same machine, the configuration needs to be modified to a new place.`) + } return err case nil: break @@ -468,6 +474,14 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment _, err = chain.InitSettlement(context.Background(), statestore, chainInfo, deployGasPrice, chainInfo.ChainID) if err != nil { fmt.Println("init settlement err: ", err) + if strings.Contains(err.Error(), "insufficient funds") { + fmt.Println("Please recharge BTT to your address to solve this error") + } + if strings.Contains(err.Error(), "contract deployment failed") { + fmt.Println(`Solution1: It is recommended to check if the balance is sufficient. If the balance is low, it is recommended to top up.`) + fmt.Println(`Solution2: Suggest to redeploy.`) + } + return err } @@ -1063,7 +1077,7 @@ func serveHTTPRemoteApi(req *cmds.Request, cctx *oldcmds.Context) (<-chan error, return errc, nil } -//collects options and opens the fuse mountpoint +// collects options and opens the fuse mountpoint func mountFuse(req *cmds.Request, cctx *oldcmds.Context) error { cfg, err := cctx.GetConfig() if err != nil { diff --git a/cmd/btfs/init.go b/cmd/btfs/init.go index 917eef8b0..17e5e6051 100644 --- a/cmd/btfs/init.go +++ b/cmd/btfs/init.go @@ -86,6 +86,9 @@ environment variable: cctx := env.(*oldcmds.Context) daemonLocked, err := fsrepo.LockedByOtherProcess(cctx.ConfigRoot) if err != nil { + fmt.Println(`What causes this error: there is already one daemon process running in background + Solution: kill it first and run btfs daemon again. + If the user has the need to start multiple nodes on the same machine, the configuration needs to be modified.`) return err } diff --git a/reportstatus/reportstatus.go b/reportstatus/reportstatus.go index b302ee0fe..1fb537a96 100644 --- a/reportstatus/reportstatus.go +++ b/reportstatus/reportstatus.go @@ -155,6 +155,9 @@ func CmdReportStatus() error { _, err := serv.ReportStatus() if err != nil { log.Errorf("ReportStatus err:%+v", err) + if strings.Contains(err.Error(), "Invalid lastNonce") { + fmt.Println("It is currently recommended to restart a new node and import the private key.") + } return err } return nil @@ -237,6 +240,9 @@ func (s *service) CheckReportStatus() error { _, err := s.ReportStatus() if err != nil { log.Errorf("ReportStatus err:%+v", err) + if strings.Contains(err.Error(), "Invalid lastNonce") { + fmt.Println("It is currently recommended to restart a new node and import the private key.") + } return err } return nil @@ -256,6 +262,10 @@ func cycleCheckReport() { //fmt.Printf("... ReportStatus, CheckReportStatus report: %+v err:%+v \n", report, err) if err != nil { log.Errorf("GetReportStatus err:%+v", err) + if strings.Contains(err.Error(), "storage: not found") { + fmt.Println(`This error is generated when the node reports status for the first time because the local data is empty. The error will disappear after the number of reports >= 2. + This error can be ignored and does not need to be handled.`) + } continue } diff --git a/settlement/swap/vault/factory.go b/settlement/swap/vault/factory.go index 94a5db0c0..729c7ea50 100644 --- a/settlement/swap/vault/factory.go +++ b/settlement/swap/vault/factory.go @@ -18,7 +18,10 @@ import ( ) var ( - ErrInvalidFactory = errors.New("not a valid factory contract") + ErrInvalidFactory = errors.New(`not a valid factory contract; + The correct way to upgrade: + 1.Make sure the current version is version 1.6.0 (or other 1.x versions) + 2.Refer to the official documentation to upgrade (https://docs.btfs.io/docs/tutorials-on-upgrading-btfs-v10-to-btfs-v20-mainnet) (Copy this link to open in your browser)`) ErrNotDeployedByFactory = errors.New("vault not deployed by factory") errDecodeABI = errors.New("could not decode abi data") @@ -283,7 +286,8 @@ func (c *factory) IsVaultCompatibleBetween(ctx context.Context, peerID1, peerID2 return } -/*GetPeerVaultWithCache query peer's vault address deployed by this factory. +/* +GetPeerVaultWithCache query peer's vault address deployed by this factory. Return cached if cache exists, otherwise query from BTTC. */ func (c *factory) GetPeerVaultWithCache(ctx context.Context, peerID peer.ID) (vault common.Address, err error) {