mirror of
https://github.com/0glabs/0g-chain.git
synced 2025-03-03 16:25:28 +00:00
refactor(x/bep3): optimize error handling by replacing fmt.Errorf with errors.New
This commit is contained in:
parent
351c2cb132
commit
01bdf29014
@ -3,6 +3,7 @@ package cli
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -179,7 +180,7 @@ func QueryGetAssetSuppliesCmd(queryRoute string) *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(res.AssetSupplies) == 0 {
|
if len(res.AssetSupplies) == 0 {
|
||||||
return fmt.Errorf("there are currently no asset supplies")
|
return errors.New("there are currently no asset supplies")
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientCtx.PrintProto(res)
|
return clientCtx.PrintProto(res)
|
||||||
|
@ -2,6 +2,7 @@ package cli
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -140,7 +141,7 @@ func GetCmdClaimAtomicSwap() *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(strings.TrimSpace(args[1])) == 0 {
|
if len(strings.TrimSpace(args[1])) == 0 {
|
||||||
return fmt.Errorf("random-number cannot be empty")
|
return errors.New("random-number cannot be empty")
|
||||||
}
|
}
|
||||||
randomNumber, err := hex.DecodeString(args[1])
|
randomNumber, err := hex.DecodeString(args[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -3,6 +3,7 @@ package keeper
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ func (k Keeper) CreateAtomicSwap(ctx sdk.Context, randomNumberHash []byte, times
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(amount) != 1 {
|
if len(amount) != 1 {
|
||||||
return fmt.Errorf("amount must contain exactly one coin")
|
return errors.New("amount must contain exactly one coin")
|
||||||
}
|
}
|
||||||
asset, err := k.GetAsset(ctx, amount[0].Denom)
|
asset, err := k.GetAsset(ctx, amount[0].Denom)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user