Add SQLite::Exception constructor that takes const char* in order to avoid possible std::bad_alloc exception

std::runtime_error provides such overload in c++11, therefore it will make no difference when compiling for c++03, but should provide no harm either
This commit is contained in:
fekir
2017-08-19 08:59:57 +02:00
parent 94ebe5ced6
commit 67ac88fb1e
2 changed files with 15 additions and 0 deletions

View File

@@ -16,6 +16,12 @@
namespace SQLite
{
Exception::Exception(const char* aErrorMessage) :
std::runtime_error(aErrorMessage),
mErrcode(-1), // 0 would be SQLITE_OK, which doesn't make sense
mExtendedErrcode(-1)
{
}
Exception::Exception(const std::string& aErrorMessage) :
std::runtime_error(aErrorMessage),
mErrcode(-1), // 0 would be SQLITE_OK, which doesn't make sense
@@ -23,6 +29,13 @@ Exception::Exception(const std::string& aErrorMessage) :
{
}
Exception::Exception(const char* aErrorMessage, int ret) :
std::runtime_error(aErrorMessage),
mErrcode(ret),
mExtendedErrcode(-1)
{
}
Exception::Exception(const std::string& aErrorMessage, int ret) :
std::runtime_error(aErrorMessage),
mErrcode(ret),