usartexception revised

This commit is contained in:
Tristan Krause 2019-06-04 10:00:41 +02:00
parent b4ac345875
commit ab82f2f90e
200 changed files with 14602 additions and 160 deletions

View file

@ -4,32 +4,43 @@
#include <exception>
#include <string>
// SOURCE: https://stackoverflow.com/a/8152888
/*! Exception for USART problems, for instance buffer overflow. */
class USARTException: public std::exception
{
public:
/**
* Constructor
* @param message as c-string
*/
explicit USARTException(const char* message) : msg(message)
{
}
/**
* Constructor
* @param message as c++-string
*/
explicit USARTException(const std::string& message) : msg(message)
{
}
virtual ~USARTException() throw ()
{
}
/**
* Standard-destructor
*/
virtual ~USARTException() = default;
/**
* Get failure description
* @return error message as c-string
*/
virtual const char* what() const throw ()
{
return msg.c_str();
}
protected:
std::string msg;
std::string msg; //!< failure description
};
#endif // USARTEXCEPTION_H