Skip to content

Commit 3441869

Browse files
committed
add custom errors
1 parent 360f166 commit 3441869

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

protocol/lighter/api.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,18 @@ func (tx *LighterTx) UnmarshalJSON(data []byte) error {
5959
return err
6060
}
6161

62+
if tx.Code != 200 {
63+
return fmt.Errorf("lighter error: code %d, message: %s", tx.Code, tx.Info)
64+
}
65+
6266
if tx.Type == TxTypeL2Transfer {
6367
var t *Transfer
6468
if err := json.Unmarshal([]byte(tx.Info), &t); err != nil {
65-
return err
69+
return fmt.Errorf("failed to unmarshal transfer: %w", err)
6670
}
6771
tx.Transfer = t
72+
} else {
73+
return fmt.Errorf("invalid transaction type: %d", tx.Type)
6874
}
6975

7076
return nil

0 commit comments

Comments
 (0)