Skip to content

Commit

Permalink
verbose error
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Mar 15, 2024
1 parent 9b447a3 commit 09fa806
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (k msgServer) Update<%= TypeName.UpperCamel %>(ctx context.Context, msg *t

// Checks if the msg <%= MsgSigner.LowerCamel %> is the same as the current owner
if msg.<%= MsgSigner.UpperCamel %> != val.<%= MsgSigner.UpperCamel %> {
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "incorrect owner")
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "incorrect owner: got %s, expected %s", msg.<%= MsgSigner.UpperCamel %>, val.<%= MsgSigner.UpperCamel %>)
}

if err := k.<%= TypeName.UpperCamel %>.Set(ctx, msg.Id, <%= TypeName.LowerCamel %>); err != nil {
Expand All @@ -76,7 +76,7 @@ func (k msgServer) Delete<%= TypeName.UpperCamel %>(ctx context.Context, msg *t

// Checks if the msg <%= MsgSigner.LowerCamel %> is the same as the current owner
if msg.<%= MsgSigner.UpperCamel %> != val.<%= MsgSigner.UpperCamel %> {
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "incorrect owner")
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "incorrect owner: got %s, expected %s", msg.<%= MsgSigner.UpperCamel %>, val.<%= MsgSigner.UpperCamel %>)
}

if err := k.<%= TypeName.UpperCamel %>.Remove(ctx, msg.Id); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (k msgServer) Update<%= TypeName.UpperCamel %>(ctx context.Context, msg *t

// Checks if the msg <%= MsgSigner.LowerCamel %> is the same as the current owner
if msg.<%= MsgSigner.UpperCamel %> != valFound.<%= MsgSigner.UpperCamel %> {
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "incorrect owner")
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "incorrect owner: got %s, expected %s", msg.<%= MsgSigner.UpperCamel %>, valFound.<%= MsgSigner.UpperCamel %>)
}

var <%= TypeName.LowerCamel %> = types.<%= TypeName.UpperCamel %>{
Expand All @@ -72,7 +72,7 @@ func (k msgServer) Delete<%= TypeName.UpperCamel %>(ctx context.Context, msg *t

// Checks if the msg <%= MsgSigner.LowerCamel %> is the same as the current owner
if msg.<%= MsgSigner.UpperCamel %> != valFound.<%= MsgSigner.UpperCamel %> {
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "incorrect owner")
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "incorrect owner: got %s, expected %s", msg.<%= MsgSigner.UpperCamel %>, valFound.<%= MsgSigner.UpperCamel %>)
}

k.Remove<%= TypeName.UpperCamel %>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ func (k msgServer) Create<%= TypeName.UpperCamel %>(ctx context.Context, msg *t

func (k msgServer) Update<%= TypeName.UpperCamel %>(ctx context.Context, msg *types.MsgUpdate<%= TypeName.UpperCamel %>) (*types.MsgUpdate<%= TypeName.UpperCamel %>Response, error) {
// Check if the value exists
valFound, err := k.<%= TypeName.UpperCamel %>.Get(ctx)
val, err := k.<%= TypeName.UpperCamel %>.Get(ctx)
if err != nil {
return nil, errorsmod.Wrap(sdkerrors.ErrKeyNotFound, "not set")
}

// Checks if the msg <%= MsgSigner.LowerCamel %> is the same as the current owner
if msg.<%= MsgSigner.UpperCamel %> != valFound.<%= MsgSigner.UpperCamel %> {
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "incorrect owner")
if msg.<%= MsgSigner.UpperCamel %> != val.<%= MsgSigner.UpperCamel %> {
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "incorrect owner: got %s, expected %s", msg.<%= MsgSigner.UpperCamel %>, val.<%= MsgSigner.UpperCamel %>)
}

var <%= TypeName.LowerCamel %> = types.<%= TypeName.UpperCamel %>{
Expand All @@ -68,7 +68,7 @@ func (k msgServer) Delete<%= TypeName.UpperCamel %>(ctx context.Context, msg *t

// Checks if the msg <%= MsgSigner.LowerCamel %> is the same as the current owner
if msg.<%= MsgSigner.UpperCamel %> != val.<%= MsgSigner.UpperCamel %> {
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "incorrect owner")
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "incorrect owner: got %s, expected %s", msg.<%= MsgSigner.UpperCamel %>, val.<%= MsgSigner.UpperCamel %>)
}

if err := k.<%= TypeName.UpperCamel %>.Remove(ctx); err != nil {
Expand Down

0 comments on commit 09fa806

Please sign in to comment.