b15f/control/src/drv/timeoutexception.h

47 lines
854 B
C
Raw Normal View History

2019-03-29 10:12:31 +00:00
#ifndef TIMEOUTEXCEPTION_H
#define TIMEOUTEXCEPTION_H
#include <exception>
2019-06-06 10:00:52 +00:00
#include <string>
2019-03-29 10:12:31 +00:00
2019-05-23 13:08:54 +00:00
/*! Exception for USART related timeouts. */
2019-03-29 10:12:31 +00:00
class TimeoutException: public std::exception
{
public:
2019-06-06 10:00:52 +00:00
/**
* Constructor
* @param message as c-string
*/
explicit TimeoutException(const char* message) : msg(message)
2019-05-23 13:08:54 +00:00
{
}
2019-03-29 10:12:31 +00:00
2019-06-06 10:00:52 +00:00
/**
* Constructor
* @param message as c++-string
*/
explicit TimeoutException(const std::string& message) : msg(message)
2019-05-23 13:08:54 +00:00
{
}
2019-03-29 10:12:31 +00:00
2019-06-06 10:00:52 +00:00
/**
* Standard-destructor
*/
virtual ~TimeoutException() = default;
2019-03-29 10:12:31 +00:00
2019-06-06 10:00:52 +00:00
/**
* Get failure description
* @return error message as c-string
*/
2019-05-23 13:08:54 +00:00
virtual const char* what() const throw ()
{
return msg.c_str();
}
2019-03-29 10:12:31 +00:00
protected:
2019-06-06 10:00:52 +00:00
std::string msg; //!< failure description
2019-03-29 10:12:31 +00:00
};
#endif // TIMEOUTEXCEPTION_H