From 719d063bd408045261e49ce822f375b3b4fad604 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Thu, 19 Sep 2024 18:07:16 +0100 Subject: [PATCH] Fix d1463f415f: Wrong type of exception thrown by invalid string parameters. `FormatString()` only catches `std::out_of_range`, but `GetNextParameter()` threw `std::runtime_error`. --- src/strings_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/strings_internal.h b/src/strings_internal.h index 4d6b1a5b7e..407d73d996 100644 --- a/src/strings_internal.h +++ b/src/strings_internal.h @@ -94,7 +94,7 @@ public: const auto ¶m = GetNextParameterReference(); const uint64_t *data = std::get_if(¶m.data); if (data != nullptr) return static_cast(*data); - throw std::runtime_error("Attempt to read string parameter as integer"); + throw std::out_of_range("Attempt to read string parameter as integer"); } /** @@ -108,7 +108,7 @@ public: const auto ¶m = GetNextParameterReference(); const std::string *data = std::get_if(¶m.data); if (data != nullptr) return data->c_str(); - throw std::runtime_error("Attempt to read integer parameter as string"); + throw std::out_of_range("Attempt to read integer parameter as string"); } /**