Skip to content

Commit

Permalink
chore: reused the usage of error in logger
Browse files Browse the repository at this point in the history
  • Loading branch information
vishal-kanna authored and DimitrisJim committed Dec 24, 2023
1 parent dbb2024 commit fffc893
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions modules/core/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,17 +856,17 @@ func (k Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgCh
}

app, ok := k.Router.GetRoute(module)
invalidroute := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
if !ok {
ctx.Logger().Error("channel upgrade ack failed", "port-id", msg.PortId, "error", invalidroute)
return nil, invalidroute
ctx.Logger().Error("channel upgrade ack failed", "port-id", msg.PortId, "error", err)
return nil, err
}

cbs, ok := app.(porttypes.UpgradableModule)
invalidupgraderoute := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to module: %s", module)
err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to module: %s", module)
if !ok {
ctx.Logger().Error("channel upgrade ack failed", "port-id", msg.PortId, "error", invalidupgraderoute)
return nil, invalidupgraderoute
ctx.Logger().Error("channel upgrade ack failed", "port-id", msg.PortId, "error", err)
return nil, err
}

err = k.ChannelKeeper.ChanUpgradeAck(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyUpgrade, msg.ProofChannel, msg.ProofUpgrade, msg.ProofHeight)
Expand Down Expand Up @@ -917,17 +917,17 @@ func (k Keeper) ChannelUpgradeConfirm(goCtx context.Context, msg *channeltypes.M
}

app, ok := k.Router.GetRoute(module)
invalidroute := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
if !ok {
ctx.Logger().Error("channel upgrade confirm failed", "port-id", msg.PortId, "error", invalidroute)
return nil, invalidroute
ctx.Logger().Error("channel upgrade confirm failed", "port-id", msg.PortId, "error", err)
return nil, err
}

cbs, ok := app.(porttypes.UpgradableModule)
invalidupgraderoute := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to module: %s", module)
err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to module: %s", module)
if !ok {
ctx.Logger().Error("channel upgrade confirm failed", "port-id", msg.PortId, "error", invalidupgraderoute)
return nil, invalidupgraderoute
ctx.Logger().Error("channel upgrade confirm failed", "port-id", msg.PortId, "error", err)
return nil, err
}

err = k.ChannelKeeper.ChanUpgradeConfirm(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyChannelState, msg.CounterpartyUpgrade, msg.ProofChannel, msg.ProofUpgrade, msg.ProofHeight)
Expand Down Expand Up @@ -979,16 +979,16 @@ func (k Keeper) ChannelUpgradeOpen(goCtx context.Context, msg *channeltypes.MsgC
}

app, ok := k.Router.GetRoute(module)
invalidroute := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
if !ok {
ctx.Logger().Error("channel upgrade open failed", "port-id", msg.PortId, "error", invalidroute)
return nil, invalidroute
ctx.Logger().Error("channel upgrade open failed", "port-id", msg.PortId, "error", err)
return nil, err
}
cbs, ok := app.(porttypes.UpgradableModule)
invalidupgraderoute := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to module: %s", module)
err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to module: %s", module)
if !ok {
ctx.Logger().Error("channel upgrade open failed", "port-id", msg.PortId, "error", invalidupgraderoute)
return nil, invalidupgraderoute
ctx.Logger().Error("channel upgrade open failed", "port-id", msg.PortId, "error", err)
return nil, err
}

if err = k.ChannelKeeper.ChanUpgradeOpen(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyChannelState, msg.ProofChannel, msg.ProofHeight); err != nil {
Expand Down Expand Up @@ -1021,18 +1021,18 @@ func (k Keeper) ChannelUpgradeTimeout(goCtx context.Context, msg *channeltypes.M
}

app, ok := k.Router.GetRoute(module)
invalidroute := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
if !ok {
ctx.Logger().Error("channel upgrade timeout failed", "port-id", msg.PortId, "error", invalidroute)
return nil, invalidroute
ctx.Logger().Error("channel upgrade timeout failed", "port-id", msg.PortId, "error", err)
return nil, err
}

cbs, ok := app.(porttypes.UpgradableModule)
invalidupgraderoute := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to module: %s", module)
err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to module: %s", module)

if !ok {
ctx.Logger().Error("channel upgrade timeout failed", "port-id", msg.PortId, "error", invalidupgraderoute)
return nil, invalidupgraderoute
ctx.Logger().Error("channel upgrade timeout failed", "port-id", msg.PortId, "error", err)
return nil, err
}

err = k.ChannelKeeper.ChanUpgradeTimeout(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyChannel, msg.ProofChannel, msg.ProofHeight)
Expand Down Expand Up @@ -1060,18 +1060,18 @@ func (k Keeper) ChannelUpgradeCancel(goCtx context.Context, msg *channeltypes.Ms
}

app, ok := k.Router.GetRoute(module)
invalidroute := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)

if !ok {
ctx.Logger().Error("channel upgrade cancel failed", "port-id", msg.PortId, "error", invalidroute)
return nil, invalidroute
ctx.Logger().Error("channel upgrade cancel failed", "port-id", msg.PortId, "error", err)
return nil, err
}

cbs, ok := app.(porttypes.UpgradableModule)
invalidupgraderoute := errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to module: %s", module)
err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "upgrade route not found to module: %s", module)
if !ok {
ctx.Logger().Error("channel upgrade cancel failed", "port-id", msg.PortId, invalidupgraderoute)
return nil, invalidupgraderoute
ctx.Logger().Error("channel upgrade cancel failed", "port-id", msg.PortId, err)
return nil, err
}

channel, found := k.ChannelKeeper.GetChannel(ctx, msg.PortId, msg.ChannelId)
Expand Down

0 comments on commit fffc893

Please sign in to comment.