usartexception revised
This commit is contained in:
parent
b4ac345875
commit
ab82f2f90e
200 changed files with 14602 additions and 160 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue