API parity with anyhow - bail / ensure, Result alias, downcast, chain#10
Merged
Conversation
- add `Result<T>` alias for `Expected<T>` in `anyhow.hpp` - add `ANYHOW_BAIL` and `ANYHOW_ENSURE` macros; short aliases under `ANYHOW_SHORT_MACROS` - add `ErrorInfo::payload` (`std::any`) and `fail_with()` for typed payloads - add `Failure::downcast<T>()` and `Failure::is<T>()` for payload inspection - add `Failure::chain()` and `Failure::root_cause()` for error inspection - add `test_failure.cpp` covering downcast, ring buffer, is, chain, root_cause - expand `test_expected.cpp` with `Result<T>` alias tests - expand `test_macros.cpp` with bail/ensure tests - drop redundant `-std=c++20` flag in tests CMake - update README and docs/vs-rust.md for new API surface - add CHANGELOG for 0.1.0 first release closes #1, closes #2
anyhow - bail / ensure, Result alias, downcast, chain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Result<T>alias forExpected<T>matching Rust's namingANYHOW_BAIL/ANYHOW_ENSUREmacros withBAIL/ENSUREshort aliasesfail_with(payload, msg, domain)+Failure::downcast<T>()/Failure::is<T>()for typed payloadsFailure::chain()andFailure::root_cause()for error inspectiontest_failure.cppcovering all newFailureAPI; expanded macro and expected testsCloses #1 and #2