usart Klasse
This commit is contained in:
parent
c1564064ac
commit
70e85ab8e9
13 changed files with 327 additions and 26 deletions
35
drv/timeoutexception.h
Normal file
35
drv/timeoutexception.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
#ifndef TIMEOUTEXCEPTION_H
|
||||
#define TIMEOUTEXCEPTION_H
|
||||
|
||||
#include <exception>
|
||||
|
||||
// SOURCE: https://stackoverflow.com/a/8152888
|
||||
|
||||
class TimeoutException: public std::exception
|
||||
{
|
||||
public:
|
||||
explicit TimeoutException(const char* message, int timeout) : TimeoutException(std::string(message), timeout)
|
||||
{
|
||||
}
|
||||
|
||||
explicit TimeoutException(const std::string& message, int timeout) : msg(message), timeout(timeout)
|
||||
{
|
||||
if(!msg.length())
|
||||
msg = "Timeout reached (" + std::to_string(timeout) + ")";
|
||||
}
|
||||
|
||||
virtual ~TimeoutException() throw ()
|
||||
{
|
||||
}
|
||||
|
||||
virtual const char* what() const throw ()
|
||||
{
|
||||
return msg.c_str();
|
||||
}
|
||||
|
||||
protected:
|
||||
std::string msg;
|
||||
int timeout;
|
||||
};
|
||||
|
||||
#endif // TIMEOUTEXCEPTION_H
|
Loading…
Add table
Add a link
Reference in a new issue