Skip to content

Commit

Permalink
fix: tidy up throwing for dispute status decode
Browse files Browse the repository at this point in the history
  • Loading branch information
0xyaco committed Oct 31, 2024
1 parent 85d5c35 commit 12f29ee
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/automated-dispute/src/services/prophetCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,21 @@ export class ProphetCodec {
* @returns The DisputeStatus string corresponding to the input value.
*/
static decodeDisputeStatus(status: number): DisputeStatus {
try {
const disputeStatus = DISPUTE_STATUS_ENUM[status];
let disputeStatus: DisputeStatus | undefined;

if (!disputeStatus) throw new ProphetDecodingError("dispute.status", toHex(status));
else return disputeStatus;
try {
disputeStatus = DISPUTE_STATUS_ENUM[status];
} catch (err) {
throw new ProphetDecodingError(
"dispute.status",
toHex(status.toString()),
err instanceof Error ? err : undefined,
);
}

if (!disputeStatus)
throw new ProphetDecodingError("dispute.status", toHex(status.toString()));
else return disputeStatus;
}

/**
Expand Down

0 comments on commit 12f29ee

Please sign in to comment.