Skip to content

Commit

Permalink
rpc: update error handling in DecDisplayForAssetID
Browse files Browse the repository at this point in the history
If an old asset didn't have this field, then we can just assume that the
value is zero, rather than error out.

Fixes #1001
  • Loading branch information
Roasbeef committed Jul 10, 2024
1 parent 5236dea commit 81d90cc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -6668,7 +6668,16 @@ func (r *rpcServer) DecDisplayForAssetID(ctx context.Context,
}

_, decDisplay, err := meta.GetDecDisplay()
if err != nil && !errors.Is(err, proof.ErrNotJSON) {
switch {
// If it isn't JSON, or doesn't have a dec display, we'll just return 0
// below.
case errors.Is(err, proof.ErrNotJSON):
fallthrough
case errors.Is(err, proof.ErrDecDisplayMissing):
break
case errors.Is(err, proof.ErrDecDisplayInvalidType):
break
case err != nil:
return 0, fmt.Errorf("unable to extract decimal "+
"display for asset_id=%v :%v", id, err)
}
Expand Down

0 comments on commit 81d90cc

Please sign in to comment.