-
Notifications
You must be signed in to change notification settings - Fork 37.4k
util: Make BResult
error a generic type instead of only bilingual_str
#25601
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
The current Ironically the original implementation #25218 that had This PR (as of 09b796a) adds back the ability to return structured error handling information, but it loses the ability to return standard error reporting information. So it is one step forward, one step backwards, IMO. I think a better solution is possible that:
I had started writing up a version of this today built on #25308. Will try to post in the next few days and we can compare notes. |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
'BResult' is a generic class useful for wrapping a return object o an error, but the error type is only `bilingual_str`. This commit changes the error for a generic type, allowing the use of this class where the error type is not `bilingual_str`.
…Destination> -BEGIN VERIFY SCRIPT- sed -i 's/BResult<CTxDestination>/SingeErrorResult<CTxDestination>/g' -- $(git grep --files-with-matches 'BResult<CTxDestination>') -END VERIFY SCRIPT-
…ransactionRef> -BEGIN VERIFY SCRIPT- sed -i 's/BResult<CTransactionRef>/SingeErrorResult<CTransactionRef>/g' -- $(git grep --files-with-matches 'BResult<CTransactionRef>') -END VERIFY SCRIPT-
…Result<CreatedTransactionResult> -BEGIN VERIFY SCRIPT- sed -i 's/BResult<CreatedTransactionResult>/SingeErrorResult<CreatedTransactionResult>/g' -- $(git grep --files-with-matches 'BResult<CreatedTransactionResult>') -END VERIFY SCRIPT-
…esult<std::unique_ptr<Wallet>> -BEGIN VERIFY SCRIPT- sed -i 's/BResult<std::unique_ptr<Wallet>>/SingeErrorResult<std::unique_ptr<Wallet>>/g' -- $(git grep --files-with-matches 'BResult<std::unique_ptr<Wallet>>') -END VERIFY SCRIPT-
Remove `class BResult` as all references to it were removed in the last commits.
@ryanofsky in 28c81d7, I added the
|
Thanks! Glad to see this (as of 696f953) adding back a standard type for error reporting. I do think there are still some issues here. The main one is that I don't see a point to the Also think it would be better to standardize on an error reporting class that can return multiple errors and warnings (and optionally format the result as a single error) than a class that can only return one error. Draft PR #25608 is a little 8000 rough but starts to go in this direction. |
Closing this in favor of #25721. |
This PR makes
BResult
error a generic type instead of onlybilingual_str
and changes the class name toStructuredResult
asBResut
is not related to the purpose of the class.The motivation is that some methods, like
src/wallet/wallet.h:{RestoreWallet(...),CreateWallet(...),LoadWallet(...)}
have more output parameters than justbilingual_str& error
such asDatabaseStatus& status
andstd::vector<bilingual_str>& warnings
.With a generic template for error, it will be possible to create a struct that has
bilingual_str& error
andDatabaseStatus& status
, for example, and use it inStructuredResult
.Built on top of #25594