Skip to content

Commit

Permalink
update error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
satawatnack committed Nov 25, 2024
1 parent 6360274 commit fe0ff59
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
30 changes: 14 additions & 16 deletions x/tunnel/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,18 @@ var (
ErrIntervalOutOfRange = errorsmod.Register(ModuleName, 4, "interval out of range")
ErrDeviationOutOfRange = errorsmod.Register(ModuleName, 5, "deviation out of range")
ErrTunnelNotFound = errorsmod.Register(ModuleName, 6, "tunnel not found")
ErrNoRoute = errorsmod.Register(ModuleName, 7, "no route")
ErrNoReceipt = errorsmod.Register(ModuleName, 8, "no receipt")
ErrLatestPricesNotFound = errorsmod.Register(ModuleName, 9, "latest prices not found")
ErrPacketNotFound = errorsmod.Register(ModuleName, 10, "packet not found")
ErrNoPacketReceipt = errorsmod.Register(ModuleName, 11, "no packet receipt")
ErrInvalidTunnelCreator = errorsmod.Register(ModuleName, 12, "invalid creator of the tunnel")
ErrAccountAlreadyExist = errorsmod.Register(ModuleName, 13, "account already exist")
ErrInvalidRoute = errorsmod.Register(ModuleName, 14, "invalid tunnel route")
ErrInactiveTunnel = errorsmod.Register(ModuleName, 15, "inactive tunnel")
ErrAlreadyActive = errorsmod.Register(ModuleName, 16, "already active")
ErrAlreadyInactive = errorsmod.Register(ModuleName, 17, "already inactive")
ErrInvalidDepositDenom = errorsmod.Register(ModuleName, 18, "invalid deposit denom")
ErrDepositNotFound = errorsmod.Register(ModuleName, 19, "deposit not found")
ErrInsufficientDeposit = errorsmod.Register(ModuleName, 20, "insufficient deposit")
ErrInsufficientFund = errorsmod.Register(ModuleName, 21, "insufficient fund")
ErrDeviationNotFound = errorsmod.Register(ModuleName, 22, "deviation not found")
ErrLatestPricesNotFound = errorsmod.Register(ModuleName, 7, "latest prices not found")
ErrPacketNotFound = errorsmod.Register(ModuleName, 8, "packet not found")
ErrNoPacketReceipt = errorsmod.Register(ModuleName, 9, "no packet receipt")
ErrInvalidTunnelCreator = errorsmod.Register(ModuleName, 10, "invalid creator of the tunnel")
ErrAccountAlreadyExist = errorsmod.Register(ModuleName, 11, "account already exist")
ErrInvalidRoute = errorsmod.Register(ModuleName, 12, "invalid tunnel route")
ErrInactiveTunnel = errorsmod.Register(ModuleName, 13, "inactive tunnel")
ErrAlreadyActive = errorsmod.Register(ModuleName, 14, "already active")
ErrAlreadyInactive = errorsmod.Register(ModuleName, 15, "already inactive")
ErrInvalidDepositDenom = errorsmod.Register(ModuleName, 16, "invalid deposit denom")
ErrDepositNotFound = errorsmod.Register(ModuleName, 17, "deposit not found")
ErrInsufficientDeposit = errorsmod.Register(ModuleName, 18, "insufficient deposit")
ErrInsufficientFund = errorsmod.Register(ModuleName, 19, "insufficient fund")
ErrDeviationNotFound = errorsmod.Register(ModuleName, 20, "deviation not found")
)
2 changes: 1 addition & 1 deletion x/tunnel/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func NewMsgCreateTSSTunnel(
func (m MsgCreateTunnel) GetRouteValue() (RouteI, error) {
r, ok := m.Route.GetCachedValue().(RouteI)
if !ok {
return nil, ErrNoRoute.Wrap("failed to get route")
return nil, sdkerrors.ErrInvalidType.Wrapf("expected %T, got %T", (RouteI)(nil), m.Route.GetCachedValue())
}
return r, nil
}
Expand Down
6 changes: 5 additions & 1 deletion x/tunnel/types/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ func (p *Packet) SetReceipt(receipt PacketReceiptI) error {
func (p Packet) GetReceiptValue() (PacketReceiptI, error) {
r, ok := p.Receipt.GetCachedValue().(PacketReceiptI)
if !ok {
return nil, sdkerrors.ErrPackAny.Wrapf("cannot unpack route")
return nil, sdkerrors.ErrInvalidType.Wrapf(
"expected %T, got %T",
(PacketReceiptI)(nil),
p.Receipt.GetCachedValue(),
)
}

return r, nil
Expand Down
7 changes: 6 additions & 1 deletion x/tunnel/types/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

feedstypes "github.com/bandprotocol/chain/v3/x/feeds/types"
)
Expand Down Expand Up @@ -77,7 +78,11 @@ func (t *Tunnel) SetRoute(route RouteI) error {
func (t Tunnel) GetRouteValue() (RouteI, error) {
r, ok := t.Route.GetCachedValue().(RouteI)
if !ok {
return nil, ErrNoRoute.Wrap("failed to get route")
return nil, sdkerrors.ErrInvalidType.Wrapf(
"expected %T, got %T",
(RouteI)(nil),
t.Route.GetCachedValue(),
)
}

return r, nil
Expand Down

0 comments on commit fe0ff59

Please sign in to comment.