wrap bitcoin_uri errors in PayjoinUriError type#661
wrap bitcoin_uri errors in PayjoinUriError type#661Johnosezele wants to merge 1 commit intopayjoin:masterfrom
Conversation
Pull Request Test Coverage Report for Build 15929207574Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
095c956 to
a5e5ab5
Compare
a5e5ab5 to
8af6c41
Compare
|
It seems like that one commit also contains formatting changes that are unrelated to the change at hand. Please narrow your commit to just do one thing. |
8af6c41 to
40a7583
Compare
40a7583 to
934435e
Compare
DanGould
left a comment
There was a problem hiding this comment.
This does not appear to wrap bitcoin_uri::de::Error which is the subject of #644. Such errors arise from the use of Uri::try_from(s: &'a str).
I believe in order to encapsulate that error we would need to change our payjoin::{Uri, PjUri} types into a wrappers rather than aliases. I would want to still be able to convert to bitcoin_uri::Uri for interoperability with other bitcoin_uri usage downstream.
The PayjoinUriError type introduced here also has unused constructors and only encapsulates an arbitrary Option<Box<dyn Error + Send + Sync>>, rather than concrete error or enumerated variants. It also prevents the continued use of a Uri after callingfn check_pj_supported(self) because the function takes ownership of the checked Uri.
I know real heart went into the drafting of the PR but it seems to me the best course of action is to close it, because it doesn't address the #644 problem i and I don't think the side effects of the change to check_pj_supported are desirable.
|
Thanks Dan. This makes things clearer now. I can see the lapses from my previous approach in addressing #644 and how it also introduces some undesirable side effects with Can I suggest a refactor to address these concerns instead of completely closing this pr? Here's my approach for a refactor, pls let me know if I'm on the right track:
I think these changes should align much better with the goal of #644 and address the concerns you raised. Pls let me know what you think. |
0428f3d to
7e3e300
Compare
- Changes payjoin::{Uri, PjUri} from type aliases to wrapper structs
- Wraps bitcoin_uri::de::Error<PjParseError> properly in PayjoinUriError::Parse variant
- Uses concrete error enums with thiserror instead of boxed errors
- Makes check_pj_supported() non-consuming to allow continued URI usage
- Enables proper FFI error handling by eliminating string-based conversions
Closes payjoin#644 likely closes payjoin#645 and payjoin#751
Contributes to payjoin#737
7e3e300 to
909a5f3
Compare
|
Hi @DanGould, I've made a complete refactor:
Also, FFI layers can now implement |
Add PayjoinUriError to provide better error handling for URI parsing. Update UriExt trait to use this new type instead of Box.
Closes #644
edit:
Wraps bitcoin_uri::de::Error properly
Closes #644 likely closes #645 and #751
Contributes to #737