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.
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.
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.