Skip to content
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

refactor: Replace BResult with util::Result #25721

Merged
merged 1 commit into from Aug 5, 2022

Commits on Aug 3, 2022

  1. refactor: Replace BResult with util::Result

    Rename `BResult` class to `util::Result` and update the class interface to be
    more compatible with `std::optional` and with a full-featured result class
    implemented in bitcoin#25665. Motivation for
    this change is to update existing `BResult` usages now so they don't have to
    change later when more features are added in bitcoin#25665.
    
    This change makes the following improvements originally implemented in bitcoin#25665:
    
    - More explicit API. Drops potentially misleading `BResult` constructor that
      treats any bilingual string argument as an error. Adds `util::Error`
      constructor so it is never ambiguous when a result is being assigned an error
      or non-error value.
    
    - Better type compatibility. Supports `util::Result<bilingual_str>` return
      values to hold translated messages which are not errors.
    
    - More standard and consistent API. `util::Result` supports most of the same
      operators and methods as `std::optional`. `BResult` had a less familiar
      interface with `HasRes`/`GetObj`/`ReleaseObj` methods. The Result/Res/Obj
      naming was also not internally consistent.
    
    - Better code organization. Puts `src/util/` code in the `util::` namespace so
      naming reflects code organization and it is obvious where the class is coming
      from. Drops "B" from name because it is undocumented what it stands for
      (bilingual?)
    
    - Has unit tests.
    ryanofsky committed Aug 3, 2022
    Configuration menu
    Copy the full SHA
    a23cca5 View commit details
    Browse the repository at this point in the history