added errorCode

This commit is contained in:
badaix 2015-08-30 23:55:24 +02:00
parent 44053417ae
commit 3a059a5764

View file

@ -26,14 +26,15 @@
// text_exception uses a dynamically-allocated internal c-string for what():
class SnapException : public std::exception {
char* text_;
int errorCode_;
public:
SnapException(const char* text)
SnapException(const char* text, int errorCode = 0) : errorCode_(errorCode)
{
text_ = new char[std::strlen(text) + 1];
std::strcpy(text_, text);
}
SnapException(const std::string& text)
SnapException(const std::string& text, int errorCode = 0) : errorCode_(errorCode)
{
text_ = new char[text.size()];
std::strcpy(text_, text.c_str());
@ -54,6 +55,11 @@ public:
{
return text_;
}
virtual int errorCode() const noexcept
{
return errorCode_;
}
};