From e3fc97dffbad63f49a90e5ae688b0ce0c282e8c2 Mon Sep 17 00:00:00 2001 From: lbckmnn <66389377+lbckmnn@users.noreply.github.com> Date: Mon, 12 Dec 2022 12:15:42 +0100 Subject: [PATCH] fix compiler warning in parseUint and catch only relevant exceptions (#2572) --- src/catch2/internal/catch_parse_numbers.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/catch2/internal/catch_parse_numbers.cpp b/src/catch2/internal/catch_parse_numbers.cpp index 390b8c87..d949ac19 100644 --- a/src/catch2/internal/catch_parse_numbers.cpp +++ b/src/catch2/internal/catch_parse_numbers.cpp @@ -6,12 +6,12 @@ // SPDX-License-Identifier: BSL-1.0 -#include - #include +#include #include #include +#include namespace Catch { @@ -39,11 +39,14 @@ namespace Catch { return {}; } return static_cast(ret); - } CATCH_CATCH_ANON( std::exception const& ) { - // There was a larger issue with the input, e.g. the parsed - // number would be too large to fit within ull. - return {}; } + CATCH_CATCH_ANON( std::invalid_argument const& ) { + // no conversion could be performed + } + CATCH_CATCH_ANON( std::out_of_range const& ) { + // the input does not fit into an unsigned long long + } + return {}; } } // namespace Catch