Code cleanup

This commit is contained in:
badaix 2020-01-10 21:28:42 +01:00
parent a75e4857e6
commit cd9f785425
7 changed files with 9 additions and 34 deletions

View file

@ -26,31 +26,22 @@
// text_exception uses a dynamically-allocated internal c-string for what():
class SnapException : public std::exception
{
char* text_;
std::string text_;
public:
SnapException(const char* text)
SnapException(const char* text) : text_(text)
{
text_ = new char[std::strlen(text) + 1];
std::strcpy(text_, text);
}
SnapException(const std::string& text) : SnapException(text.c_str())
{
}
SnapException(const SnapException& e) : SnapException(e.what())
{
}
~SnapException() throw() override
{
delete[] text_;
}
~SnapException() throw() override = default;
const char* what() const noexcept override
{
return text_;
return text_.c_str();
}
};
@ -67,11 +58,6 @@ public:
{
}
AsyncSnapException(const AsyncSnapException& e) : SnapException(e.what())
{
}
~AsyncSnapException() throw() override = default;
};