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 
8 class TimeoutException: public std::exception
9 {
10 public:
11  explicit TimeoutException(const char* message, int timeout) : TimeoutException(std::string(message), timeout)
12  {
13  }
14 
15  explicit TimeoutException(const std::string& message, int timeout) : msg(message), m_timeout(timeout)
16  {
17  if(!msg.length())
18  msg = "Timeout reached (" + std::to_string(m_timeout) + ")";
19  }
20 
21  virtual ~TimeoutException() throw ()
22  {
23  }
24 
25  virtual const char* what() const throw ()
26  {
27  return msg.c_str();
28  }
29 
30 protected:
31  std::string msg;
32  int m_timeout;
33 };
34 
35 #endif // TIMEOUTEXCEPTION_H
TimeoutException
Definition: timeoutexception.h:8