Skip to content

Commit

Permalink
feat: update error log
Browse files Browse the repository at this point in the history
  • Loading branch information
Shawn-Huang-Tron committed Oct 26, 2022
1 parent 58fd31a commit 586bd7f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
16 changes: 15 additions & 1 deletion cmd/btfs/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions cmd/btfs/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
10 changes: 10 additions & 0 deletions reportstatus/reportstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
}

Expand Down
8 changes: 6 additions & 2 deletions settlement/swap/vault/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 586bd7f

Please sign in to comment.