#include "cpr/timeout.h" #include #include #include #include namespace cpr { // No way around since curl uses a long here. // NOLINTNEXTLINE(google-runtime-int) long Timeout::Milliseconds() const { static_assert(std::is_same::value, "Following casting expects milliseconds."); // No way around since curl uses a long here. // NOLINTNEXTLINE(google-runtime-int) if (ms.count() > static_cast(std::numeric_limits::max())) { throw std::overflow_error("cpr::Timeout: timeout value overflow: " + std::to_string(ms.count()) + " ms."); } // No way around since curl uses a long here. // NOLINTNEXTLINE(google-runtime-int) if (ms.count() < static_cast(std::numeric_limits::min())) { throw std::underflow_error("cpr::Timeout: timeout value underflow: " + std::to_string(ms.count()) + " ms."); } // No way around since curl uses a long here. // NOLINTNEXTLINE(google-runtime-int) return static_cast(ms.count()); } } // namespace cpr