snapcast/common/snapException.h
(no author) abf70b4030 logging
git-svn-id: svn://elaine/murooma/trunk@330 d8a302eb-03bc-478d-80e4-98257eca68ef
2014-12-29 17:33:54 +00:00

53 lines
829 B
C++

#ifndef SNAP_EXCEPTION_H
#define SNAP_EXCEPTION_H
#include <exception>
#include <string>
#include <cstring> // std::strlen, std::strcpy
// text_exception uses a dynamically-allocated internal c-string for what():
class SnapException : public std::exception {
char* text_;
public:
SnapException(const char* text)
{
text_ = new char[std::strlen(text)];
std::strcpy(text_, text);
}
SnapException(const SnapException& e)
{
text_ = new char[std::strlen(e.text_)];
std::strcpy(text_, e.text_);
}
virtual ~SnapException() throw()
{
delete[] text_;
}
virtual const char* what() const noexcept
{
return text_;
}
};
class ServerException : public SnapException
{
public:
ServerException(const char* text) : SnapException(text)
{
}
virtual ~ServerException() throw()
{
}
};
#endif