-
Notifications
You must be signed in to change notification settings - Fork 169
Refactor: make descriptors::key::DescriptorKeyParseError an enum #804
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
Conversation
Can you add the boilerplate? I know it's annoying to write but it makes things much more maintainable since it forces a visible API change whenever we add or change variants. |
@apoelstra no problem, please see 895da06 Before the PR I had them all as 'top-level' error variants and it was a bit unwieldily, I think the above is a better middle ground. |
|
In 895da06: You need to re-export the new error type |
|
Other than those two comments 895da06 looks great! Thanks for grinding through this. |
|
Thanks for the review @apoelstra
Let me know if you would prefer all the commits in this PR to be squashed into one. |
|
Yes please -- can you just squash everything? |
refactor: add MalformedKeyDataKind enum to DescriptorKeyParseError definition fix: re-export MalformedKeyDataKind from descriptor module root fix: allow missing docs on C-style MalformedKeyDataKind enum fix: start error strings with lowercase in descriptors::key module
|
Sorted and noted for the future |
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.
ACK 497c5a3; successfully ran local tests; thanks!
…ey::DescriptorKeyParseError an enum 497c5a31974e9a19f8b3b5286edb323281957147 refactor: make descriptors::key::DescriptorKeyParseError an enum (Chris Ricketts) Pull request description: This PR has a go at refactoring `DescriptorKeyParseError` into an enum, as suggested in the `FIXME` comment: https://github.com/rust-bitcoin/rust-miniscript/blob/d0da327417cb177884c5d77edffa0891ba9b6969/src/descriptor/key.rs#L327-L330 I have separated the error variants by different inner parse error types and result types (e.g, public key, private key, etc) where I think it made sense to retain the inner error. I left a variant that wraps a `&'static str` and its used for the various ad-hoc parsing errors instead of adding the boilerplate for variants only created once and without retained data. The generic `parse_xkey_deriv` function now takes a parse function as its first parameter to allow specific key parsing errors: https://github.com/chris-ricketts/rust-miniscript/blob/790b08fcf46f53ce6ee80355a7db8e5108ed860f/src/descriptor/key.rs#L935-L952 ACKs for top commit: apoelstra: ACK 497c5a31974e9a19f8b3b5286edb323281957147; successfully ran local tests; thanks! Tree-SHA512: c9fb26b6484c90124947912070e9cca4e93b4d3bdb674a07926fb1a1adc6fe2c272a1d38925b35fc4842a527651a45b00dc6381d057bb02f36006dbda653809b
This PR has a go at refactoring
DescriptorKeyParseErrorinto an enum, as suggested in theFIXMEcomment:rust-miniscript/src/descriptor/key.rs
Lines 327 to 330 in d0da327
I have separated the error variants by different inner parse error types and result types (e.g, public key, private key, etc) where I think it made sense to retain the inner error.
I left a variant that wraps a
&'static strand its used for the various ad-hoc parsing errors instead of adding the boilerplate for variants only created once and without retained data.The generic
parse_xkey_derivfunction now takes a parse function as its first parameter to allow specific key parsing errors:https://github.com/chris-ricketts/rust-miniscript/blob/790b08fcf46f53ce6ee80355a7db8e5108ed860f/src/descriptor/key.rs#L935-L952