Skip to content

Commit 2ea95f2

Browse files
committed
Add ERROR_HANDLING to make macros more explicit
1 parent 8f07152 commit 2ea95f2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/ystdlib/error_handling/Result.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ using Result = OUTCOME_V2_NAMESPACE::std_result<ReturnType, ErrorType>;
4444
* Only supported on AppleClang, Clang, and GCC due to reliance on Outcome's TRY macros.
4545
*/
4646
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
47-
#define YSTDLIB_TRYX(expr) (OUTCOME_TRYX(expr))
47+
#define YSTDLIB_ERROR_HANDLING_TRYX(expr) (OUTCOME_TRYX(expr))
4848

4949
/**
5050
* Error propagation macro for expressions that return void on success.
@@ -55,7 +55,7 @@ using Result = OUTCOME_V2_NAMESPACE::std_result<ReturnType, ErrorType>;
5555
* Only supported on AppleClang, Clang, and GCC due to reliance on Outcome's TRY macros.
5656
*/
5757
// NOLINTNEXTLINE(cppcoreguidelines-avoid-do-while, cppcoreguidelines-macro-usage)
58-
#define YSTDLIB_TRYV(expr) \
58+
#define YSTDLIB_ERROR_HANDLING_TRYV(expr) \
5959
do { \
6060
OUTCOME_TRYV(expr); \
6161
} while (false)

src/ystdlib/error_handling/test/test_Result.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ TEST_CASE("test_result_void", "[error_handling][Result]") {
4141

4242
TEST_CASE("test_result_void_in_main", "[error_handling][Result]") {
4343
auto main_func = [&](bool is_error) -> Result<void> {
44-
YSTDLIB_TRYV(cVoidFunc(is_error));
44+
YSTDLIB_ERROR_HANDLING_TRYV(cVoidFunc(is_error));
4545
return success();
4646
};
4747
auto const main_no_error{main_func(false)};
@@ -65,7 +65,7 @@ TEST_CASE("test_result_int", "[error_handling][Result]") {
6565

6666
TEST_CASE("test_result_int_in_main", "[error_handling][Result]") {
6767
auto main_func = [&](bool is_error) -> Result<void> {
68-
YSTDLIB_TRYV(cIntFunc(is_error));
68+
YSTDLIB_ERROR_HANDLING_TRYV(cIntFunc(is_error));
6969
return success();
7070
};
7171
auto const main_no_error{main_func(false)};
@@ -78,7 +78,9 @@ TEST_CASE("test_result_int_in_main", "[error_handling][Result]") {
7878
}
7979

8080
TEST_CASE("test_result_int_propagate", "[error_handling][Result]") {
81-
auto main_func = [&](bool is_error) -> Result<int> { return YSTDLIB_TRYX(cIntFunc(is_error)); };
81+
auto main_func = [&](bool is_error) -> Result<int> {
82+
return YSTDLIB_ERROR_HANDLING_TRYX(cIntFunc(is_error));
83+
};
8284
auto const main_no_error{main_func(false)};
8385
REQUIRE_FALSE(main_no_error.has_error());
8486
REQUIRE((cTestInt == main_no_error.value()));

0 commit comments

Comments
 (0)