coral
A C++ library for distributed co-simulation
exception.hpp
Go to the documentation of this file.
1 
10 #ifndef CORAL_SLAVE_EXCEPTION_HPP_INCLUDED
11 #define CORAL_SLAVE_EXCEPTION_HPP_INCLUDED
12 
13 #include <chrono>
14 #include <stdexcept>
15 #include <string>
16 #include <coral/config.h>
17 
18 
19 namespace coral
20 {
21 namespace slave
22 {
23 
24 
27 {
28 public:
29  explicit TimeoutException(std::chrono::milliseconds timeoutDuration) CORAL_NOEXCEPT
30  : std::runtime_error("Slave timed out due to lack of communication"),
31  m_timeoutDuration(timeoutDuration)
32  {
33  }
34 
36  const std::string& message,
37  std::chrono::milliseconds timeoutDuration) CORAL_NOEXCEPT
39  message + " (timeout: " + std::to_string(timeoutDuration.count()) + " ms)")
40  , m_timeoutDuration(timeoutDuration)
41  {
42  }
43 
46  {
47  return m_timeoutDuration;
48  }
49 
50 private:
51  std::chrono::milliseconds m_timeoutDuration;
52 };
53 
54 
55 }} // namespace
56 #endif // header guard
T to_string(T...args)
STL class.
Thrown when a communications timeout is reached.
Definition: exception.hpp:26
Definition: variable_io.hpp:28
std::chrono::milliseconds TimeoutDuration() const CORAL_NOEXCEPT
The duration of the timeout that was reached.
Definition: exception.hpp:45