From eab2ea9fc2c183dfa2d45b196fd8002fb41aa489 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 26 Dec 2021 07:05:45 -0800 Subject: [PATCH] Replace an assert with an exception --- include/fmt/chrono.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 05e9de87..85680b3b 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -1403,10 +1403,8 @@ inline Int to_nonnegative_int(T value, Int upper) { } template ::value)> inline Int to_nonnegative_int(T value, Int upper) { - FMT_ASSERT( - std::isnan(value) || (value >= 0 && value <= static_cast(upper)), - "invalid value"); - (void)upper; + if (value < 0 || value > static_cast(upper)) + throw format_error("invalid value"); return static_cast(value); }