timeout.cpp
Go to the documentation of this file.
1 #include "cpr/timeout.h"
2 
3 #include <limits>
4 #include <stdexcept>
5 #include <string>
6 #include <type_traits>
7 
8 namespace cpr {
9 
10 long Timeout::Milliseconds() const {
11  static_assert(std::is_same<std::chrono::milliseconds, decltype(ms)>::value,
12  "Following casting expects milliseconds.");
13 
14  if (ms.count() > std::numeric_limits<long>::max()) {
15  throw std::overflow_error(
16  "cpr::Timeout: timeout value overflow: " + std::to_string(ms.count()) + " ms.");
17  }
18  if (ms.count() < std::numeric_limits<long>::min()) {
19  throw std::underflow_error(
20  "cpr::Timeout: timeout value underflow: " + std::to_string(ms.count()) + " ms.");
21  }
22 
23  return static_cast<long>(ms.count());
24 }
25 
26 } // namespace cpr
std::chrono::milliseconds ms
Definition: timeout.h:16
Definition: auth.cpp:3
UNITTEST_START int * value
Definition: unit1602.c:51
long Milliseconds() const
Definition: timeout.cpp:10


rc_tagdetect_client
Author(s): Monika Florek-Jasinska , Raphael Schaller
autogenerated on Sat Feb 13 2021 03:42:16