mirror of
https://github.com/badaix/snapcast.git
synced 2025-08-06 01:58:42 +02:00
added errorCode
This commit is contained in:
parent
44053417ae
commit
3a059a5764
1 changed files with 14 additions and 8 deletions
|
@ -26,34 +26,40 @@
|
||||||
// text_exception uses a dynamically-allocated internal c-string for what():
|
// text_exception uses a dynamically-allocated internal c-string for what():
|
||||||
class SnapException : public std::exception {
|
class SnapException : public std::exception {
|
||||||
char* text_;
|
char* text_;
|
||||||
|
int errorCode_;
|
||||||
public:
|
public:
|
||||||
SnapException(const char* text)
|
SnapException(const char* text, int errorCode = 0) : errorCode_(errorCode)
|
||||||
{
|
{
|
||||||
text_ = new char[std::strlen(text) + 1];
|
text_ = new char[std::strlen(text) + 1];
|
||||||
std::strcpy(text_, text);
|
std::strcpy(text_, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
SnapException(const std::string& text)
|
SnapException(const std::string& text, int errorCode = 0) : errorCode_(errorCode)
|
||||||
{
|
{
|
||||||
text_ = new char[text.size()];
|
text_ = new char[text.size()];
|
||||||
std::strcpy(text_, text.c_str());
|
std::strcpy(text_, text.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
SnapException(const SnapException& e)
|
SnapException(const SnapException& e)
|
||||||
{
|
{
|
||||||
text_ = new char[std::strlen(e.text_)];
|
text_ = new char[std::strlen(e.text_)];
|
||||||
std::strcpy(text_, e.text_);
|
std::strcpy(text_, e.text_);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~SnapException() throw()
|
virtual ~SnapException() throw()
|
||||||
{
|
{
|
||||||
delete[] text_;
|
delete[] text_;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const char* what() const noexcept
|
virtual const char* what() const noexcept
|
||||||
{
|
{
|
||||||
return text_;
|
return text_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual int errorCode() const noexcept
|
||||||
|
{
|
||||||
|
return errorCode_;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue