Skip to content

Commit

Permalink
Replace an assert with an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Dec 26, 2021
1 parent 21ed92a commit eab2ea9
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions include/fmt/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -1403,10 +1403,8 @@ inline Int to_nonnegative_int(T value, Int upper) {
}
template <typename T, typename Int, FMT_ENABLE_IF(!std::is_integral<T>::value)>
inline Int to_nonnegative_int(T value, Int upper) {
FMT_ASSERT(
std::isnan(value) || (value >= 0 && value <= static_cast<T>(upper)),
"invalid value");
(void)upper;
if (value < 0 || value > static_cast<T>(upper))
throw format_error("invalid value");
return static_cast<Int>(value);
}

Expand Down

0 comments on commit eab2ea9

Please sign in to comment.