-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: handle decoding errors #80
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great 💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good 👍 , just some comments
constructor( | ||
public readonly id: string, | ||
public readonly data: ByteArray | Hex, | ||
public readonly err?: Error, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
although is optional, you're not using err
, maybe want to remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! The idea was to log the name of the original error to provide more context during debugging to the user. Ended up logging this err
's name too
try { | ||
const disputeStatus = DISPUTE_STATUS_ENUM[status]; | ||
|
||
if (!disputeStatus) throw new ProphetDecodingError("dispute.status", toHex(status)); | ||
else return disputeStatus; | ||
} catch (err) { | ||
throw new ProphetDecodingError( | ||
"dispute.status", | ||
toHex(status.toString()), | ||
err instanceof Error ? err : undefined, | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it correct to throw, catch and throw the same error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Big 🧠, fixed
try { | ||
AddRequest.buildFromEvent(malformedRequestEvent, registry); | ||
|
||
fail("Expecting error"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooo didn't know this trick
f7d5e47
to
6431356
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a commit suggestion and is good to go
try { | ||
disputeStatus = DISPUTE_STATUS_ENUM[status]; | ||
} catch (err) { | ||
throw new ProphetDecodingError( | ||
"dispute.status", | ||
toHex(status.toString()), | ||
err instanceof Error ? err : undefined, | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try { | |
disputeStatus = DISPUTE_STATUS_ENUM[status]; | |
} catch (err) { | |
throw new ProphetDecodingError( | |
"dispute.status", | |
toHex(status.toString()), | |
err instanceof Error ? err : undefined, | |
); | |
} | |
disputeStatus = DISPUTE_STATUS_ENUM[status]; |
try/catch is not needed anymore right?
🤖 Linear
Closes GRT-242
Description
bytes
properties read from Prophet eventsProphetCodec.decode...
calls from ProtocolProvidergetXXXEvent
to use them during actual event processing and not event fetching