B15F
Board 15 Famulus Edition
timeoutexception.h
1 #ifndef TIMEOUTEXCEPTION_H
2 #define TIMEOUTEXCEPTION_H
3 
4 #include <exception>
5 
6 // SOURCE: https://stackoverflow.com/a/8152888
7 
10 class TimeoutException: public std::exception
11 {
12 public:
13  explicit TimeoutException(const char* message, int timeout) : TimeoutException(std::string(message), timeout)
14  {
15  }
16 
17  explicit TimeoutException(const std::string& message, int timeout) : msg(message), m_timeout(timeout)
18  {
19  if(!msg.length())
20  msg = "Timeout reached (" + std::to_string(m_timeout) + ")";
21  }
22 
23  virtual ~TimeoutException() throw ()
24  {
25  }
26 
27  virtual const char* what() const throw ()
28  {
29  return msg.c_str();
30  }
31 
32 protected:
33  std::string msg;
34  int m_timeout;
35 };
36 
37 #endif // TIMEOUTEXCEPTION_H
TimeoutException
Definition: timeoutexception.h:10