-
Notifications
You must be signed in to change notification settings - Fork 7
Replace panics and simple errors with custom error types #37
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
base: master
Are you sure you want to change the base?
Replace panics and simple errors with custom error types #37
Conversation
|
CI passed: 8384b9 |
|
In a548ad8: Rather than doing |
| "020000000000000000000000000000000000000000000000000000000000000000", | ||
| ], | ||
| "Execution failed: invalid pubkey: Encoding(Secp256k1(InvalidPublicKey))\n", | ||
| "Execution failed: invalid pubkey: string error\n", |
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.
In a548ad8:
Heh, this is unfortunate. It's ultimately a bug in rust-bitcoin's ParsePublicKeyError that its errors have a terrible Display impl. Nothing we can do here.
apoelstra
left a comment
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.
On 8384b92 successfully ran local tests
In the Err match arm for output handling, I kept panics to trigger the existing panic hook. This preserve the same output formatting and as their old counterparts, even though the newer commands use cmd::print_output |
df35c9c to
c3b23ec
Compare
One of the PRs in a series addressing issue #28.
In the legacy commands (
address,block,tx), panic-based logic has been removed from the execution path and replaced with custom errors.For the remaining commands,
crate::cmd::simplicity::Errorhas been removed from the execution logic in favor of command-specific custom errors.This change is crucial for enabling programmable interfaces, as it allows errors to be caught and handled programmatically by inspecting the underlying error chain rather than relying on catching panics or parsing of string errors.