forked from qt-creator/qt-creator
Sqlite: Inject RTTI into TU
We had problems on macOS with the catching of exceptions because the has type_info::hash_code was different. This is probably a bug because RTTI code is injected for an inline class. To work around that problem we implemented the virtual what method for every exception. Task-number: QDS-9266 Change-Id: I79052c8b70adead412d1940b17195151fb19ebb9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
This commit is contained in:
@@ -79,7 +79,7 @@ void BaseStatement::waitForUnlockNotify() const
|
||||
&unlockNotification);
|
||||
|
||||
if (resultCode == SQLITE_LOCKED)
|
||||
throw DeadLock("SqliteStatement::waitForUnlockNotify: database is in a dead lock!");
|
||||
throw DeadLock();
|
||||
|
||||
unlockNotification.wait();
|
||||
}
|
||||
@@ -490,13 +490,13 @@ void BaseStatement::checkForBindingError(int resultCode) const
|
||||
void BaseStatement::checkBindingParameterCount(int bindingParameterCount) const
|
||||
{
|
||||
if (bindingParameterCount != sqlite3_bind_parameter_count(m_compiledStatement.get()))
|
||||
throw WrongBindingParameterCount{"Sqlite: wrong binding parameter count!"};
|
||||
throw WrongBindingParameterCount{};
|
||||
}
|
||||
|
||||
void BaseStatement::checkColumnCount(int columnCount) const
|
||||
{
|
||||
if (columnCount != sqlite3_column_count(m_compiledStatement.get()))
|
||||
throw WrongColumnCount{"Sqlite: wrong column count!"};
|
||||
throw WrongColumnCount{};
|
||||
}
|
||||
|
||||
bool BaseStatement::isReadOnlyStatement() const
|
||||
@@ -504,102 +504,102 @@ bool BaseStatement::isReadOnlyStatement() const
|
||||
return sqlite3_stmt_readonly(m_compiledStatement.get());
|
||||
}
|
||||
|
||||
void BaseStatement::throwStatementIsBusy(const char *whatHasHappened) const
|
||||
void BaseStatement::throwStatementIsBusy(const char *) const
|
||||
{
|
||||
throw StatementIsBusy(whatHasHappened, sqlite3_errmsg(sqliteDatabaseHandle()));
|
||||
throw StatementIsBusy(sqlite3_errmsg(sqliteDatabaseHandle()));
|
||||
}
|
||||
|
||||
void BaseStatement::throwStatementHasError(const char *whatHasHappened) const
|
||||
void BaseStatement::throwStatementHasError(const char *) const
|
||||
{
|
||||
throw StatementHasError(whatHasHappened, sqlite3_errmsg(sqliteDatabaseHandle()));
|
||||
throw StatementHasError(sqlite3_errmsg(sqliteDatabaseHandle()));
|
||||
}
|
||||
|
||||
void BaseStatement::throwStatementIsMisused(const char *whatHasHappened) const
|
||||
void BaseStatement::throwStatementIsMisused(const char *) const
|
||||
{
|
||||
throw StatementIsMisused(whatHasHappened, sqlite3_errmsg(sqliteDatabaseHandle()));
|
||||
throw StatementIsMisused(sqlite3_errmsg(sqliteDatabaseHandle()));
|
||||
}
|
||||
|
||||
void BaseStatement::throwInputOutputError(const char *whatHasHappened) const
|
||||
void BaseStatement::throwInputOutputError(const char *) const
|
||||
{
|
||||
throw InputOutputError(whatHasHappened);
|
||||
throw InputOutputError();
|
||||
}
|
||||
|
||||
void BaseStatement::throwConstraintPreventsModification(const char *whatHasHappened) const
|
||||
void BaseStatement::throwConstraintPreventsModification(const char *) const
|
||||
{
|
||||
throw ConstraintPreventsModification(whatHasHappened, sqlite3_errmsg(sqliteDatabaseHandle()));
|
||||
throw ConstraintPreventsModification(sqlite3_errmsg(sqliteDatabaseHandle()));
|
||||
}
|
||||
|
||||
void BaseStatement::throwNoValuesToFetch(const char *whatHasHappened) const
|
||||
void BaseStatement::throwNoValuesToFetch(const char *) const
|
||||
{
|
||||
throw NoValuesToFetch(whatHasHappened);
|
||||
throw NoValuesToFetch();
|
||||
}
|
||||
|
||||
void BaseStatement::throwBindingIndexIsOutOfRange(const char *whatHasHappened) const
|
||||
void BaseStatement::throwBindingIndexIsOutOfRange(const char *) const
|
||||
{
|
||||
throw BindingIndexIsOutOfRange(whatHasHappened, sqlite3_errmsg(sqliteDatabaseHandle()));
|
||||
throw BindingIndexIsOutOfRange(sqlite3_errmsg(sqliteDatabaseHandle()));
|
||||
}
|
||||
|
||||
void BaseStatement::throwUnknowError(const char *whatHasHappened) const
|
||||
{
|
||||
if (sqliteDatabaseHandle())
|
||||
throw UnknowError(whatHasHappened, sqlite3_errmsg(sqliteDatabaseHandle()));
|
||||
throw UnknowError(sqlite3_errmsg(sqliteDatabaseHandle()));
|
||||
else
|
||||
throw UnknowError(whatHasHappened);
|
||||
}
|
||||
|
||||
void BaseStatement::throwBingingTooBig(const char *whatHasHappened) const
|
||||
void BaseStatement::throwBingingTooBig(const char *) const
|
||||
{
|
||||
throw BindingTooBig(whatHasHappened, sqlite3_errmsg(sqliteDatabaseHandle()));
|
||||
throw BindingTooBig(sqlite3_errmsg(sqliteDatabaseHandle()));
|
||||
}
|
||||
|
||||
void BaseStatement::throwTooBig(const char *whatHasHappened) const
|
||||
void BaseStatement::throwTooBig(const char *) const
|
||||
{
|
||||
throw TooBig{whatHasHappened, sqlite3_errmsg(sqliteDatabaseHandle())};
|
||||
throw TooBig{sqlite3_errmsg(sqliteDatabaseHandle())};
|
||||
}
|
||||
|
||||
void BaseStatement::throwSchemaChangeError(const char *whatHasHappened) const
|
||||
void BaseStatement::throwSchemaChangeError(const char *) const
|
||||
{
|
||||
throw SchemeChangeError{whatHasHappened, sqlite3_errmsg(sqliteDatabaseHandle())};
|
||||
throw SchemeChangeError{sqlite3_errmsg(sqliteDatabaseHandle())};
|
||||
}
|
||||
|
||||
void BaseStatement::throwCannotWriteToReadOnlyConnection(const char *whatHasHappened) const
|
||||
void BaseStatement::throwCannotWriteToReadOnlyConnection(const char *) const
|
||||
{
|
||||
throw CannotWriteToReadOnlyConnection{whatHasHappened, sqlite3_errmsg(sqliteDatabaseHandle())};
|
||||
throw CannotWriteToReadOnlyConnection{sqlite3_errmsg(sqliteDatabaseHandle())};
|
||||
}
|
||||
|
||||
void BaseStatement::throwProtocolError(const char *whatHasHappened) const
|
||||
void BaseStatement::throwProtocolError(const char *) const
|
||||
{
|
||||
throw ProtocolError{whatHasHappened, sqlite3_errmsg(sqliteDatabaseHandle())};
|
||||
throw ProtocolError{sqlite3_errmsg(sqliteDatabaseHandle())};
|
||||
}
|
||||
|
||||
void BaseStatement::throwDatabaseExceedsMaximumFileSize(const char *whatHasHappened) const
|
||||
void BaseStatement::throwDatabaseExceedsMaximumFileSize(const char *) const
|
||||
{
|
||||
throw DatabaseExceedsMaximumFileSize{whatHasHappened, sqlite3_errmsg(sqliteDatabaseHandle())};
|
||||
throw DatabaseExceedsMaximumFileSize{sqlite3_errmsg(sqliteDatabaseHandle())};
|
||||
}
|
||||
|
||||
void BaseStatement::throwDataTypeMismatch(const char *whatHasHappened) const
|
||||
void BaseStatement::throwDataTypeMismatch(const char *) const
|
||||
{
|
||||
throw DataTypeMismatch{whatHasHappened, sqlite3_errmsg(sqliteDatabaseHandle())};
|
||||
throw DataTypeMismatch{sqlite3_errmsg(sqliteDatabaseHandle())};
|
||||
}
|
||||
|
||||
void BaseStatement::throwConnectionIsLocked(const char *whatHasHappened) const
|
||||
void BaseStatement::throwConnectionIsLocked(const char *) const
|
||||
{
|
||||
throw ConnectionIsLocked{whatHasHappened, sqlite3_errmsg(sqliteDatabaseHandle())};
|
||||
throw ConnectionIsLocked{sqlite3_errmsg(sqliteDatabaseHandle())};
|
||||
}
|
||||
|
||||
void BaseStatement::throwExecutionInterrupted(const char *whatHasHappened) const
|
||||
void BaseStatement::throwExecutionInterrupted(const char *) const
|
||||
{
|
||||
throw ExecutionInterrupted{whatHasHappened};
|
||||
throw ExecutionInterrupted{};
|
||||
}
|
||||
|
||||
void BaseStatement::throwDatabaseIsCorrupt(const char *whatHasHappened) const
|
||||
void BaseStatement::throwDatabaseIsCorrupt(const char *) const
|
||||
{
|
||||
throw DatabaseIsCorrupt{whatHasHappened};
|
||||
throw DatabaseIsCorrupt{};
|
||||
}
|
||||
|
||||
void BaseStatement::throwCannotOpen(const char *whatHasHappened) const
|
||||
void BaseStatement::throwCannotOpen(const char *) const
|
||||
{
|
||||
throw CannotOpen{whatHasHappened};
|
||||
throw CannotOpen{};
|
||||
}
|
||||
|
||||
QString BaseStatement::columnName(int column) const
|
||||
|
||||
@@ -417,7 +417,7 @@ private:
|
||||
: statement(statement)
|
||||
{
|
||||
if (statement && !statement->database().isLocked())
|
||||
throw DatabaseIsNotLocked{"Database connection is not locked!"};
|
||||
throw DatabaseIsNotLocked{};
|
||||
}
|
||||
|
||||
Resetter(Resetter &) = delete;
|
||||
|
||||
@@ -259,15 +259,17 @@ void DatabaseBackend::registerBusyHandler()
|
||||
void DatabaseBackend::checkForOpenDatabaseWhichCanBeClosed()
|
||||
{
|
||||
if (m_databaseHandle == nullptr)
|
||||
throw DatabaseIsAlreadyClosed("SqliteDatabaseBackend::close: database is not open so it cannot be closed.");
|
||||
throw DatabaseIsAlreadyClosed();
|
||||
}
|
||||
|
||||
void DatabaseBackend::checkDatabaseClosing(int resultCode)
|
||||
{
|
||||
switch (resultCode) {
|
||||
case SQLITE_OK: return;
|
||||
case SQLITE_BUSY: throw DatabaseIsBusy("SqliteDatabaseBackend::close: database is busy because of e.g. unfinalized statements and will stay open!");
|
||||
default: throwUnknowError("SqliteDatabaseBackend::close: unknown error happens at closing!");
|
||||
case SQLITE_BUSY:
|
||||
throw DatabaseIsBusy();
|
||||
default:
|
||||
throw UnknowError("SqliteDatabaseBackend::close: unknown error happens at closing!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,8 +279,7 @@ void DatabaseBackend::checkCanOpenDatabase(Utils::SmallStringView databaseFilePa
|
||||
throw DatabaseFilePathIsEmpty("SqliteDatabaseBackend::SqliteDatabaseBackend: database cannot be opened because the file path is empty!");
|
||||
|
||||
if (!QFileInfo::exists(QFileInfo(QString(databaseFilePath)).path()))
|
||||
throw WrongFilePath("SqliteDatabaseBackend::SqliteDatabaseBackend: database cannot be opened because of wrong file path!",
|
||||
Utils::SmallString(databaseFilePath));
|
||||
throw WrongFilePath(Utils::SmallString(databaseFilePath));
|
||||
|
||||
if (databaseIsOpen())
|
||||
throw DatabaseIsAlreadyOpen("SqliteDatabaseBackend::SqliteDatabaseBackend: database cannot be opened because it is already open!");
|
||||
@@ -291,76 +292,69 @@ void DatabaseBackend::checkDatabaseCouldBeOpened(int resultCode)
|
||||
return;
|
||||
default:
|
||||
closeWithoutException();
|
||||
throw UnknowError(
|
||||
"SqliteDatabaseBackend::SqliteDatabaseBackend: database cannot be opened:",
|
||||
sqlite3_errmsg(sqliteDatabaseHandle()));
|
||||
throw UnknowError(sqlite3_errmsg(sqliteDatabaseHandle()));
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseBackend::checkCarrayCannotBeIntialized(int resultCode)
|
||||
{
|
||||
if (resultCode != SQLITE_OK)
|
||||
throwDatabaseIsNotOpen(
|
||||
"SqliteDatabaseBackend: database cannot be opened because carray failed!");
|
||||
throw DatabaseIsNotOpen();
|
||||
}
|
||||
|
||||
void DatabaseBackend::checkPragmaValue(Utils::SmallStringView databaseValue,
|
||||
Utils::SmallStringView expectedValue)
|
||||
{
|
||||
if (databaseValue != expectedValue)
|
||||
throw PragmaValueNotSet("SqliteDatabaseBackend::setPragmaValue: pragma value is not set!");
|
||||
throw PragmaValueNotSet();
|
||||
}
|
||||
|
||||
void DatabaseBackend::checkDatabaseHandleIsNotNull() const
|
||||
{
|
||||
if (m_databaseHandle == nullptr)
|
||||
throwDatabaseIsNotOpen("SqliteDatabaseBackend: database is not open!");
|
||||
throw DatabaseIsNotOpen();
|
||||
}
|
||||
|
||||
void DatabaseBackend::checkIfMultithreadingIsActivated(int resultCode)
|
||||
{
|
||||
if (resultCode != SQLITE_OK)
|
||||
throwExceptionStatic(
|
||||
"SqliteDatabaseBackend::activateMultiThreading: multithreading can't be activated!");
|
||||
throw MultiTheadingCannotBeActivated{};
|
||||
}
|
||||
|
||||
void DatabaseBackend::checkIfLoogingIsActivated(int resultCode)
|
||||
{
|
||||
if (resultCode != SQLITE_OK)
|
||||
throwExceptionStatic("SqliteDatabaseBackend::activateLogging: logging can't be activated!");
|
||||
throw LoggingCannotBeActivated{};
|
||||
}
|
||||
|
||||
void DatabaseBackend::checkMmapSizeIsSet(int resultCode)
|
||||
{
|
||||
if (resultCode != SQLITE_OK)
|
||||
throwExceptionStatic(
|
||||
"SqliteDatabaseBackend::checkMmapSizeIsSet: mmap size can't be changed!");
|
||||
throw MemoryMappingCannotBeChanged{};
|
||||
}
|
||||
|
||||
void DatabaseBackend::checkInitializeSqliteLibraryWasSuccesful(int resultCode)
|
||||
{
|
||||
if (resultCode != SQLITE_OK)
|
||||
throwExceptionStatic(
|
||||
"SqliteDatabaseBackend::initializeSqliteLibrary: SqliteLibrary cannot initialized!");
|
||||
throw LibraryCannotBeInitialized{};
|
||||
}
|
||||
|
||||
void DatabaseBackend::checkShutdownSqliteLibraryWasSuccesful(int resultCode)
|
||||
{
|
||||
if (resultCode != SQLITE_OK)
|
||||
throwExceptionStatic(
|
||||
"SqliteDatabaseBackend::shutdownSqliteLibrary: SqliteLibrary cannot be shutdowned!");
|
||||
throw LibraryCannotBeShutdown{};
|
||||
}
|
||||
|
||||
void DatabaseBackend::checkIfLogCouldBeCheckpointed(int resultCode)
|
||||
{
|
||||
if (resultCode != SQLITE_OK)
|
||||
throwException("SqliteDatabaseBackend::checkpointFullWalLog: WAL log could not be checkpointed!");
|
||||
throw LogCannotBeCheckpointed{};
|
||||
}
|
||||
|
||||
void DatabaseBackend::checkIfBusyTimeoutWasSet(int resultCode)
|
||||
{
|
||||
if (resultCode != SQLITE_OK)
|
||||
throwException("SqliteDatabaseBackend::setBusyTimeout: Busy timeout cannot be set!");
|
||||
throw BusyTimerCannotBeSet{};
|
||||
}
|
||||
|
||||
namespace {
|
||||
@@ -392,7 +386,7 @@ JournalMode DatabaseBackend::pragmaToJournalMode(Utils::SmallStringView pragma)
|
||||
int index = indexOfPragma(pragma, journalModeStrings);
|
||||
|
||||
if (index < 0)
|
||||
throwExceptionStatic("SqliteDatabaseBackend::pragmaToJournalMode: pragma can't be transformed in a journal mode enumeration!");
|
||||
throw PragmaValueCannotBeTransformed{};
|
||||
|
||||
return static_cast<JournalMode>(index);
|
||||
}
|
||||
@@ -429,15 +423,14 @@ void DatabaseBackend::walCheckpointFull()
|
||||
case SQLITE_BUSY_SNAPSHOT:
|
||||
case SQLITE_BUSY_TIMEOUT:
|
||||
case SQLITE_BUSY:
|
||||
throw DatabaseIsBusy("DatabaseBackend::walCheckpointFull: Operation could not concluded "
|
||||
"because database is busy!");
|
||||
throw DatabaseIsBusy();
|
||||
case SQLITE_ERROR_MISSING_COLLSEQ:
|
||||
case SQLITE_ERROR_RETRY:
|
||||
case SQLITE_ERROR_SNAPSHOT:
|
||||
case SQLITE_ERROR:
|
||||
throwException("DatabaseBackend::walCheckpointFull: Error occurred!");
|
||||
throw LogCannotBeCheckpointed{};
|
||||
case SQLITE_MISUSE:
|
||||
throwExceptionStatic("DatabaseBackend::walCheckpointFull: Misuse of database!");
|
||||
throw CheckpointIsMisused{};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -489,29 +482,6 @@ void DatabaseBackend::resetProgressHandler()
|
||||
sqlite3_progress_handler(sqliteDatabaseHandle(), 0, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void DatabaseBackend::throwExceptionStatic(const char *whatHasHappens)
|
||||
{
|
||||
throw Exception(whatHasHappens);
|
||||
}
|
||||
|
||||
void DatabaseBackend::throwException(const char *whatHasHappens) const
|
||||
{
|
||||
if (m_databaseHandle)
|
||||
throw ExceptionWithMessage(whatHasHappens, sqlite3_errmsg(m_databaseHandle));
|
||||
else
|
||||
throw Exception(whatHasHappens);
|
||||
}
|
||||
|
||||
void DatabaseBackend::throwUnknowError(const char *whatHasHappens) const
|
||||
{
|
||||
throw UnknowError(whatHasHappens);
|
||||
}
|
||||
|
||||
void DatabaseBackend::throwDatabaseIsNotOpen(const char *whatHasHappens) const
|
||||
{
|
||||
throw DatabaseIsNotOpen(whatHasHappens);
|
||||
}
|
||||
|
||||
template<typename Type>
|
||||
Type DatabaseBackend::toValue(Utils::SmallStringView sqlStatement) const
|
||||
{
|
||||
|
||||
@@ -108,11 +108,6 @@ protected:
|
||||
static Utils::SmallStringView journalModeToPragma(JournalMode journalMode);
|
||||
static JournalMode pragmaToJournalMode(Utils::SmallStringView pragma);
|
||||
|
||||
Q_NORETURN static void throwExceptionStatic(const char *whatHasHappens);
|
||||
[[noreturn]] void throwException(const char *whatHasHappens) const;
|
||||
[[noreturn]] void throwUnknowError(const char *whatHasHappens) const;
|
||||
[[noreturn]] void throwDatabaseIsNotOpen(const char *whatHasHappens) const;
|
||||
|
||||
private:
|
||||
Database &m_database;
|
||||
sqlite3 *m_databaseHandle;
|
||||
|
||||
@@ -11,7 +11,12 @@ namespace Sqlite {
|
||||
|
||||
const char *Exception::what() const noexcept
|
||||
{
|
||||
return m_whatErrorHasHappen;
|
||||
return "Sqlite::Exception";
|
||||
}
|
||||
|
||||
const char *ExceptionWithMessage::what() const noexcept
|
||||
{
|
||||
return "Sqlite::ExceptionWithMessage";
|
||||
}
|
||||
|
||||
void ExceptionWithMessage::printWarning() const
|
||||
@@ -19,4 +24,279 @@ void ExceptionWithMessage::printWarning() const
|
||||
qWarning() << what() << m_sqliteErrorMessage;
|
||||
}
|
||||
|
||||
const char *StatementIsBusy::what() const noexcept
|
||||
{
|
||||
return "Sqlite::StatementIsBusy";
|
||||
}
|
||||
|
||||
const char *DatabaseIsBusy::what() const noexcept
|
||||
{
|
||||
return "Sqlite::DatabaseIsBusy";
|
||||
}
|
||||
|
||||
const char *StatementHasError::what() const noexcept
|
||||
{
|
||||
return "Sqlite::StatementHasError";
|
||||
}
|
||||
|
||||
const char *StatementIsMisused::what() const noexcept
|
||||
{
|
||||
return "Sqlite::StatementIsMisused";
|
||||
}
|
||||
|
||||
const char *InputOutputError::what() const noexcept
|
||||
{
|
||||
return "Sqlite::InputOutputError";
|
||||
}
|
||||
|
||||
const char *ConstraintPreventsModification::what() const noexcept
|
||||
{
|
||||
return "Sqlite::ConstraintPreventsModification";
|
||||
}
|
||||
|
||||
const char *NoValuesToFetch::what() const noexcept
|
||||
{
|
||||
return "Sqlite::NoValuesToFetch";
|
||||
}
|
||||
|
||||
const char *BindingIndexIsOutOfRange::what() const noexcept
|
||||
{
|
||||
return "Sqlite::BindingIndexIsOutOfRange";
|
||||
}
|
||||
|
||||
const char *WrongBindingName::what() const noexcept
|
||||
{
|
||||
return "Sqlite::WrongBindingName";
|
||||
}
|
||||
|
||||
const char *DatabaseIsNotOpen::what() const noexcept
|
||||
{
|
||||
return "Sqlite::DatabaseIsNotOpen";
|
||||
}
|
||||
|
||||
const char *DatabaseCannotBeOpened::what() const noexcept
|
||||
{
|
||||
return "Sqlite::DatabaseCannotBeOpened";
|
||||
}
|
||||
|
||||
const char *DatabaseFilePathIsEmpty::what() const noexcept
|
||||
{
|
||||
return "Sqlite::DatabaseFilePathIsEmpty";
|
||||
}
|
||||
|
||||
const char *DatabaseIsAlreadyOpen::what() const noexcept
|
||||
{
|
||||
return "Sqlite::DatabaseIsAlreadyOpen";
|
||||
}
|
||||
|
||||
const char *DatabaseCannotBeClosed::what() const noexcept
|
||||
{
|
||||
return "Sqlite::DatabaseCannotBeClosed";
|
||||
}
|
||||
|
||||
const char *DatabaseIsAlreadyClosed::what() const noexcept
|
||||
{
|
||||
return "Sqlite::DatabaseIsAlreadyClosed";
|
||||
}
|
||||
|
||||
const char *WrongFilePath::what() const noexcept
|
||||
{
|
||||
return "Sqlite::WrongFilePath";
|
||||
}
|
||||
|
||||
const char *PragmaValueNotSet::what() const noexcept
|
||||
{
|
||||
return "Sqlite::PragmaValueNotSet";
|
||||
}
|
||||
|
||||
const char *NotReadOnlySqlStatement::what() const noexcept
|
||||
{
|
||||
return "Sqlite::NotReadOnlySqlStatement";
|
||||
}
|
||||
|
||||
const char *NotWriteSqlStatement::what() const noexcept
|
||||
{
|
||||
return "Sqlite::NotWriteSqlStatement";
|
||||
}
|
||||
|
||||
const char *DeadLock::what() const noexcept
|
||||
{
|
||||
return "Sqlite::DeadLock";
|
||||
}
|
||||
|
||||
const char *UnknowError::what() const noexcept
|
||||
{
|
||||
return "Sqlite::UnknowError";
|
||||
}
|
||||
|
||||
const char *BindingTooBig::what() const noexcept
|
||||
{
|
||||
return "Sqlite::BindingTooBig";
|
||||
}
|
||||
|
||||
const char *TooBig::what() const noexcept
|
||||
{
|
||||
return "Sqlite::TooBig";
|
||||
}
|
||||
|
||||
const char *CannotConvert::what() const noexcept
|
||||
{
|
||||
return "Sqlite::CannotConvert";
|
||||
}
|
||||
|
||||
const char *ForeignKeyColumnIsNotUnique::what() const noexcept
|
||||
{
|
||||
return "Sqlite::ForeignKeyColumnIsNotUnique";
|
||||
}
|
||||
|
||||
const char *CannotApplyChangeSet::what() const noexcept
|
||||
{
|
||||
return "Sqlite::CannotApplyChangeSet";
|
||||
}
|
||||
|
||||
const char *ChangeSetIsMisused::what() const noexcept
|
||||
{
|
||||
return "Sqlite::ChangeSetIsMisused";
|
||||
}
|
||||
|
||||
const char *SchemeChangeError::what() const noexcept
|
||||
{
|
||||
return "Sqlite::SchemeChangeError";
|
||||
}
|
||||
|
||||
const char *CannotWriteToReadOnlyConnection::what() const noexcept
|
||||
{
|
||||
return "Sqlite::CannotWriteToReadOnlyConnection";
|
||||
}
|
||||
|
||||
const char *ProtocolError::what() const noexcept
|
||||
{
|
||||
return "Sqlite::ProtocolError";
|
||||
}
|
||||
|
||||
const char *DatabaseExceedsMaximumFileSize::what() const noexcept
|
||||
{
|
||||
return "Sqlite::DatabaseExceedsMaximumFileSize";
|
||||
}
|
||||
|
||||
const char *DataTypeMismatch::what() const noexcept
|
||||
{
|
||||
return "Sqlite::DataTypeMismatch";
|
||||
}
|
||||
|
||||
const char *ConnectionIsLocked::what() const noexcept
|
||||
{
|
||||
return "Sqlite::ConnectionIsLocked";
|
||||
}
|
||||
|
||||
const char *ExecutionInterrupted::what() const noexcept
|
||||
{
|
||||
return "Sqlite::ExecutionInterrupted";
|
||||
}
|
||||
|
||||
const char *DatabaseIsCorrupt::what() const noexcept
|
||||
{
|
||||
return "Sqlite::DatabaseIsCorrupt";
|
||||
}
|
||||
|
||||
const char *CannotOpen::what() const noexcept
|
||||
{
|
||||
return "Sqlite::CannotOpen";
|
||||
}
|
||||
|
||||
const char *CannotCreateChangeSetIterator::what() const noexcept
|
||||
{
|
||||
return "Sqlite::CannotCreateChangeSetIterator";
|
||||
}
|
||||
|
||||
const char *CannotGetChangeSetOperation::what() const noexcept
|
||||
{
|
||||
return "Sqlite::CannotGetChangeSetOperation";
|
||||
}
|
||||
|
||||
const char *ChangeSetTupleIsOutOfRange::what() const noexcept
|
||||
{
|
||||
return "Sqlite::ChangeSetTupleIsOutOfRange";
|
||||
}
|
||||
|
||||
const char *ChangeSetTupleIsMisused::what() const noexcept
|
||||
{
|
||||
return "Sqlite::ChangeSetTupleIsMisused";
|
||||
}
|
||||
|
||||
const char *UnknownError::what() const noexcept
|
||||
{
|
||||
return "Sqlite::UnknownError";
|
||||
}
|
||||
|
||||
const char *DatabaseIsNotLocked::what() const noexcept
|
||||
{
|
||||
return "Sqlite::DatabaseIsNotLocked";
|
||||
}
|
||||
|
||||
const char *WrongBindingParameterCount::what() const noexcept
|
||||
{
|
||||
return "Sqlite::WrongBindingParameterCount";
|
||||
}
|
||||
|
||||
const char *WrongColumnCount::what() const noexcept
|
||||
{
|
||||
return "Sqlite::WrongColumnCount";
|
||||
}
|
||||
|
||||
const char *IndexHasNoTableName::what() const noexcept
|
||||
{
|
||||
return "Sqlite::IndexHasNoTableName";
|
||||
}
|
||||
|
||||
const char *IndexHasNoColumns::what() const noexcept
|
||||
{
|
||||
return "Sqlite::IndexHasNoColumns";
|
||||
}
|
||||
|
||||
const char *MultiTheadingCannotBeActivated::what() const noexcept
|
||||
{
|
||||
return "Sqlite::MultiTheadingCannotBeActivated";
|
||||
}
|
||||
|
||||
const char *LoggingCannotBeActivated::what() const noexcept
|
||||
{
|
||||
return "Sqlite::LoggingCannotBeActivated";
|
||||
}
|
||||
|
||||
const char *MemoryMappingCannotBeChanged::what() const noexcept
|
||||
{
|
||||
return "Sqlite::MemoryMappingCannotBeChanged";
|
||||
}
|
||||
|
||||
const char *LibraryCannotBeInitialized::what() const noexcept
|
||||
{
|
||||
return "Sqlite::LibraryCannotBeInitialized";
|
||||
}
|
||||
|
||||
const char *LibraryCannotBeShutdown::what() const noexcept
|
||||
{
|
||||
return "Sqlite::LibraryCannotBeShutdown";
|
||||
}
|
||||
|
||||
const char *LogCannotBeCheckpointed::what() const noexcept
|
||||
{
|
||||
return "Sqlite::LogCannotBeCheckPointed";
|
||||
}
|
||||
|
||||
const char *BusyTimerCannotBeSet::what() const noexcept
|
||||
{
|
||||
return "Sqlite::BusyTimerCannotBeSet";
|
||||
}
|
||||
|
||||
const char *PragmaValueCannotBeTransformed::what() const noexcept
|
||||
{
|
||||
return "Sqlite::PragmaValueCannotBeTransformed";
|
||||
}
|
||||
|
||||
const char *CheckpointIsMisused::what() const noexcept
|
||||
{
|
||||
return "Sqlite::CheckpointIsMisused";
|
||||
}
|
||||
|
||||
} // namespace Sqlite
|
||||
|
||||
@@ -15,293 +15,407 @@ namespace Sqlite {
|
||||
class SQLITE_EXPORT Exception : public std::exception
|
||||
{
|
||||
public:
|
||||
Exception(const char *whatErrorHasHappen)
|
||||
: m_whatErrorHasHappen(whatErrorHasHappen)
|
||||
{}
|
||||
|
||||
Exception() = default;
|
||||
const char *what() const noexcept override;
|
||||
|
||||
private:
|
||||
const char *m_whatErrorHasHappen;
|
||||
};
|
||||
|
||||
class SQLITE_EXPORT ExceptionWithMessage : public Exception
|
||||
{
|
||||
public:
|
||||
ExceptionWithMessage(const char *whatErrorHasHappen,
|
||||
Utils::SmallString &&sqliteErrorMessage = Utils::SmallString{})
|
||||
: Exception{whatErrorHasHappen}
|
||||
, m_sqliteErrorMessage(std::move(sqliteErrorMessage))
|
||||
ExceptionWithMessage(Utils::SmallString &&sqliteErrorMessage = Utils::SmallString{})
|
||||
: m_sqliteErrorMessage(std::move(sqliteErrorMessage))
|
||||
{}
|
||||
|
||||
const char *what() const noexcept override;
|
||||
void printWarning() const;
|
||||
|
||||
private:
|
||||
Utils::SmallString m_sqliteErrorMessage;
|
||||
};
|
||||
|
||||
class StatementIsBusy : public ExceptionWithMessage
|
||||
class SQLITE_EXPORT StatementIsBusy : public ExceptionWithMessage
|
||||
{
|
||||
public:
|
||||
using ExceptionWithMessage::ExceptionWithMessage;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class DatabaseIsBusy : public Exception
|
||||
class SQLITE_EXPORT DatabaseIsBusy : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class StatementHasError : public ExceptionWithMessage
|
||||
class SQLITE_EXPORT StatementHasError : public ExceptionWithMessage
|
||||
{
|
||||
public:
|
||||
using ExceptionWithMessage::ExceptionWithMessage;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class StatementIsMisused : public ExceptionWithMessage
|
||||
class SQLITE_EXPORT StatementIsMisused : public ExceptionWithMessage
|
||||
{
|
||||
public:
|
||||
using ExceptionWithMessage::ExceptionWithMessage;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class InputOutputError : public Exception
|
||||
class SQLITE_EXPORT InputOutputError : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class ConstraintPreventsModification : public ExceptionWithMessage
|
||||
class SQLITE_EXPORT ConstraintPreventsModification : public ExceptionWithMessage
|
||||
{
|
||||
public:
|
||||
using ExceptionWithMessage::ExceptionWithMessage;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class NoValuesToFetch : public Exception
|
||||
class SQLITE_EXPORT NoValuesToFetch : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class BindingIndexIsOutOfRange : public ExceptionWithMessage
|
||||
class SQLITE_EXPORT BindingIndexIsOutOfRange : public ExceptionWithMessage
|
||||
{
|
||||
public:
|
||||
using ExceptionWithMessage::ExceptionWithMessage;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class WrongBindingName : public Exception
|
||||
class SQLITE_EXPORT WrongBindingName : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class DatabaseIsNotOpen : public Exception
|
||||
class SQLITE_EXPORT DatabaseIsNotOpen : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class DatabaseCannotBeOpened : public ExceptionWithMessage
|
||||
class SQLITE_EXPORT DatabaseCannotBeOpened : public ExceptionWithMessage
|
||||
{
|
||||
public:
|
||||
using ExceptionWithMessage::ExceptionWithMessage;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class DatabaseFilePathIsEmpty : public DatabaseCannotBeOpened
|
||||
class SQLITE_EXPORT DatabaseFilePathIsEmpty : public DatabaseCannotBeOpened
|
||||
{
|
||||
public:
|
||||
using DatabaseCannotBeOpened::DatabaseCannotBeOpened;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class DatabaseIsAlreadyOpen : public DatabaseCannotBeOpened
|
||||
class SQLITE_EXPORT DatabaseIsAlreadyOpen : public DatabaseCannotBeOpened
|
||||
{
|
||||
public:
|
||||
using DatabaseCannotBeOpened::DatabaseCannotBeOpened;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class DatabaseCannotBeClosed : public Exception
|
||||
class SQLITE_EXPORT DatabaseCannotBeClosed : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class DatabaseIsAlreadyClosed : public DatabaseCannotBeClosed
|
||||
class SQLITE_EXPORT DatabaseIsAlreadyClosed : public DatabaseCannotBeClosed
|
||||
{
|
||||
public:
|
||||
using DatabaseCannotBeClosed::DatabaseCannotBeClosed;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class WrongFilePath : public ExceptionWithMessage
|
||||
class SQLITE_EXPORT WrongFilePath : public ExceptionWithMessage
|
||||
{
|
||||
public:
|
||||
using ExceptionWithMessage::ExceptionWithMessage;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class PragmaValueNotSet : public Exception
|
||||
class SQLITE_EXPORT PragmaValueNotSet : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class NotReadOnlySqlStatement : public Exception
|
||||
class SQLITE_EXPORT PragmaValueCannotBeTransformed : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class NotWriteSqlStatement : public Exception
|
||||
class SQLITE_EXPORT NotReadOnlySqlStatement : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class DeadLock : public Exception
|
||||
class SQLITE_EXPORT NotWriteSqlStatement : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class UnknowError : public ExceptionWithMessage
|
||||
class SQLITE_EXPORT DeadLock : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class SQLITE_EXPORT UnknowError : public ExceptionWithMessage
|
||||
{
|
||||
public:
|
||||
using ExceptionWithMessage::ExceptionWithMessage;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class BindingTooBig : public ExceptionWithMessage
|
||||
class SQLITE_EXPORT BindingTooBig : public ExceptionWithMessage
|
||||
{
|
||||
public:
|
||||
using ExceptionWithMessage::ExceptionWithMessage;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class TooBig : public ExceptionWithMessage
|
||||
class SQLITE_EXPORT TooBig : public ExceptionWithMessage
|
||||
{
|
||||
public:
|
||||
using ExceptionWithMessage::ExceptionWithMessage;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class CannotConvert : public Exception
|
||||
class SQLITE_EXPORT CannotConvert : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class ForeignKeyColumnIsNotUnique : public Exception
|
||||
class SQLITE_EXPORT ForeignKeyColumnIsNotUnique : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class CannotApplyChangeSet : public Exception
|
||||
class SQLITE_EXPORT CannotApplyChangeSet : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class ChangeSetIsMisused : public Exception
|
||||
class SQLITE_EXPORT ChangeSetIsMisused : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class SchemeChangeError : public ExceptionWithMessage
|
||||
class SQLITE_EXPORT SchemeChangeError : public ExceptionWithMessage
|
||||
{
|
||||
public:
|
||||
using ExceptionWithMessage::ExceptionWithMessage;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class CannotWriteToReadOnlyConnection : public ExceptionWithMessage
|
||||
class SQLITE_EXPORT CannotWriteToReadOnlyConnection : public ExceptionWithMessage
|
||||
{
|
||||
public:
|
||||
using ExceptionWithMessage::ExceptionWithMessage;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class ProtocolError : public ExceptionWithMessage
|
||||
class SQLITE_EXPORT ProtocolError : public ExceptionWithMessage
|
||||
{
|
||||
public:
|
||||
using ExceptionWithMessage::ExceptionWithMessage;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class DatabaseExceedsMaximumFileSize : public ExceptionWithMessage
|
||||
class SQLITE_EXPORT DatabaseExceedsMaximumFileSize : public ExceptionWithMessage
|
||||
{
|
||||
public:
|
||||
using ExceptionWithMessage::ExceptionWithMessage;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class DataTypeMismatch : public ExceptionWithMessage
|
||||
class SQLITE_EXPORT DataTypeMismatch : public ExceptionWithMessage
|
||||
{
|
||||
public:
|
||||
using ExceptionWithMessage::ExceptionWithMessage;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class ConnectionIsLocked : public ExceptionWithMessage
|
||||
class SQLITE_EXPORT ConnectionIsLocked : public ExceptionWithMessage
|
||||
{
|
||||
public:
|
||||
using ExceptionWithMessage::ExceptionWithMessage;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class ExecutionInterrupted : public ExceptionWithMessage
|
||||
{
|
||||
public:
|
||||
using ExceptionWithMessage::ExceptionWithMessage;
|
||||
};
|
||||
|
||||
class DatabaseIsCorrupt : public ExceptionWithMessage
|
||||
{
|
||||
public:
|
||||
using ExceptionWithMessage::ExceptionWithMessage;
|
||||
};
|
||||
|
||||
class CannotOpen : public ExceptionWithMessage
|
||||
{
|
||||
public:
|
||||
using ExceptionWithMessage::ExceptionWithMessage;
|
||||
};
|
||||
|
||||
class CannotCreateChangeSetIterator : public Exception
|
||||
class SQLITE_EXPORT ExecutionInterrupted : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class CannotGetChangeSetOperation : public Exception
|
||||
class SQLITE_EXPORT DatabaseIsCorrupt : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class ChangeSetTupleIsOutOfRange : public Exception
|
||||
class SQLITE_EXPORT CannotOpen : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class ChangeSetTupleIsMisused : public Exception
|
||||
class SQLITE_EXPORT CannotCreateChangeSetIterator : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class UnknownError : public Exception
|
||||
class SQLITE_EXPORT CannotGetChangeSetOperation : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class DatabaseIsNotLocked : public Exception
|
||||
class SQLITE_EXPORT ChangeSetTupleIsOutOfRange : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class WrongBindingParameterCount : public Exception
|
||||
class SQLITE_EXPORT ChangeSetTupleIsMisused : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class WrongColumnCount : public Exception
|
||||
class SQLITE_EXPORT UnknownError : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class SQLITE_EXPORT DatabaseIsNotLocked : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class SQLITE_EXPORT WrongBindingParameterCount : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class SQLITE_EXPORT WrongColumnCount : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class SQLITE_EXPORT IndexHasNoTableName : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class SQLITE_EXPORT IndexHasNoColumns : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class SQLITE_EXPORT MultiTheadingCannotBeActivated : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class SQLITE_EXPORT LoggingCannotBeActivated : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class SQLITE_EXPORT MemoryMappingCannotBeChanged : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class SQLITE_EXPORT LibraryCannotBeInitialized : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class SQLITE_EXPORT LibraryCannotBeShutdown : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class SQLITE_EXPORT LogCannotBeCheckpointed : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class SQLITE_EXPORT BusyTimerCannotBeSet : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
class SQLITE_EXPORT CheckpointIsMisused : public Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
const char *what() const noexcept override;
|
||||
};
|
||||
|
||||
} // namespace Sqlite
|
||||
|
||||
@@ -55,13 +55,13 @@ public:
|
||||
void checkTableName() const
|
||||
{
|
||||
if (m_tableName.isEmpty())
|
||||
throw Exception("SqliteIndex has not table name!");
|
||||
throw IndexHasNoTableName();
|
||||
}
|
||||
|
||||
void checkColumns() const
|
||||
{
|
||||
if (m_columnNames.empty())
|
||||
throw Exception("SqliteIndex has no columns!");
|
||||
throw IndexHasNoColumns();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -91,8 +91,7 @@ protected:
|
||||
void checkIsReadOnlyStatement()
|
||||
{
|
||||
if (!Base::isReadOnlyStatement())
|
||||
throw NotReadOnlySqlStatement(
|
||||
"SqliteStatement::SqliteReadStatement: is not read only statement!");
|
||||
throw NotReadOnlySqlStatement();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -26,15 +26,13 @@ void checkSessionChangeSetCreation(int resultCode)
|
||||
void checkIteratorCreation(int resultCode)
|
||||
{
|
||||
if (resultCode != SQLITE_OK)
|
||||
throw Sqlite::CannotCreateChangeSetIterator{
|
||||
"SessionChangeSet: Cannot create iterator from blob."};
|
||||
throw Sqlite::CannotCreateChangeSetIterator{};
|
||||
}
|
||||
|
||||
void checkIteratorOperation(int resultCode)
|
||||
{
|
||||
if (resultCode != SQLITE_OK)
|
||||
throw Sqlite::CannotGetChangeSetOperation{
|
||||
"SessionChangeSet: Cannot create iterator from blob."};
|
||||
throw Sqlite::CannotGetChangeSetOperation{};
|
||||
}
|
||||
|
||||
void checkChangeSetValue(int resultCode)
|
||||
@@ -43,14 +41,12 @@ void checkChangeSetValue(int resultCode)
|
||||
case SQLITE_OK:
|
||||
return;
|
||||
case SQLITE_RANGE:
|
||||
throw Sqlite::ChangeSetTupleIsOutOfRange{
|
||||
"SessionChangeSet: You tried to access a non existing column."};
|
||||
throw Sqlite::ChangeSetTupleIsOutOfRange{};
|
||||
case SQLITE_MISUSE:
|
||||
throw Sqlite::ChangeSetIsMisused{
|
||||
"SessionChangeSet: Some misuse happened as you tried to access."};
|
||||
throw Sqlite::ChangeSetIsMisused{};
|
||||
}
|
||||
|
||||
throw Sqlite::UnknownError{"SessionChangeSet: Some unknown error happened."};
|
||||
throw Sqlite::UnknownError{};
|
||||
}
|
||||
|
||||
ValueView convertSqliteValue(sqlite3_value *value)
|
||||
|
||||
@@ -20,13 +20,13 @@ void checkResultCode(int resultCode)
|
||||
case SQLITE_NOMEM:
|
||||
throw std::bad_alloc();
|
||||
case SQLITE_SCHEMA:
|
||||
throw CannotApplyChangeSet("Cannot apply change set!");
|
||||
throw CannotApplyChangeSet();
|
||||
case SQLITE_MISUSE:
|
||||
throw ChangeSetIsMisused("Change set is misused!");
|
||||
throw ChangeSetIsMisused();
|
||||
}
|
||||
|
||||
if (resultCode != SQLITE_OK)
|
||||
throw UnknowError("Unknow exception");
|
||||
throw UnknowError();
|
||||
}
|
||||
|
||||
int xConflict(void *, int conflict, sqlite3_changeset_iter *)
|
||||
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
Constraints &&constraints = {})
|
||||
{
|
||||
if (!constainsUniqueIndex(referencedColumn.constraints))
|
||||
throw ForeignKeyColumnIsNotUnique("Foreign column key must be unique!");
|
||||
throw ForeignKeyColumnIsNotUnique();
|
||||
|
||||
constraints.emplace_back(ForeignKey{referencedColumn.tableName,
|
||||
referencedColumn.name,
|
||||
|
||||
@@ -347,7 +347,7 @@ private:
|
||||
case QVariant::ByteArray:
|
||||
return VariantType{Blob{value.toByteArray()}};
|
||||
default:
|
||||
throw CannotConvert("Cannot convert this QVariant to a ValueBase");
|
||||
throw CannotConvert();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,7 +365,7 @@ private:
|
||||
case ValueType::Blob:
|
||||
return VariantType{view.toBlobView()};
|
||||
default:
|
||||
throw CannotConvert("Cannot convert this QVariant to a ValueBase");
|
||||
throw CannotConvert();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,8 +28,7 @@ protected:
|
||||
void checkIsWritableStatement()
|
||||
{
|
||||
if (Base::isReadOnlyStatement())
|
||||
throw NotWriteSqlStatement(
|
||||
"SqliteStatement::SqliteWriteStatement: is not a writable statement!");
|
||||
throw NotWriteSqlStatement();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -197,30 +197,37 @@ void SqlStatementBuilder::checkIfPlaceHolderExists(Utils::SmallStringView name)
|
||||
void SqlStatementBuilder::checkIfNoPlaceHoldersAynmoreExists() const
|
||||
{
|
||||
if (m_sqlStatement.contains('$'))
|
||||
throwException("SqlStatementBuilder::bind: there are still placeholder in the sql statement!", m_sqlTemplate.constData());
|
||||
throwException(
|
||||
"SqlStatementBuilder::bind: there are still placeholder in the sql statement!",
|
||||
m_sqlTemplate);
|
||||
}
|
||||
|
||||
void SqlStatementBuilder::checkBindingTextIsNotEmpty(Utils::SmallStringView text) const
|
||||
{
|
||||
if (text.isEmpty())
|
||||
throwException("SqlStatementBuilder::bind: binding text it empty!", m_sqlTemplate.constData());
|
||||
throwException("SqlStatementBuilder::bind: binding text it empty!", m_sqlTemplate);
|
||||
}
|
||||
|
||||
void SqlStatementBuilder::checkBindingTextVectorIsNotEmpty(const Utils::SmallStringVector &textVector) const
|
||||
{
|
||||
if (textVector.empty())
|
||||
throwException("SqlStatementBuilder::bind: binding text vector it empty!", m_sqlTemplate.constData());
|
||||
throwException("SqlStatementBuilder::bind: binding text vector it empty!", m_sqlTemplate);
|
||||
}
|
||||
|
||||
void SqlStatementBuilder::checkBindingIntegerVectorIsNotEmpty(const std::vector<int> &integerVector) const
|
||||
{
|
||||
if (integerVector.empty())
|
||||
throwException("SqlStatementBuilder::bind: binding integer vector it empty!", m_sqlTemplate.constData());
|
||||
throwException("SqlStatementBuilder::bind: binding integer vector it empty!", m_sqlTemplate);
|
||||
}
|
||||
|
||||
void SqlStatementBuilder::throwException(const char *whatHasHappened, const char *errorMessage)
|
||||
void SqlStatementBuilder::throwException(const char *whatHasHappened, Utils::SmallString sqlTemplate)
|
||||
{
|
||||
throw SqlStatementBuilderException(whatHasHappened, errorMessage);
|
||||
throw SqlStatementBuilderException(whatHasHappened, std::move(sqlTemplate));
|
||||
}
|
||||
|
||||
const char *SqlStatementBuilderException::what() const noexcept
|
||||
{
|
||||
return m_whatHasHappened;
|
||||
}
|
||||
|
||||
} // namespace Sqlite
|
||||
|
||||
@@ -52,7 +52,8 @@ protected:
|
||||
void checkBindingTextVectorIsNotEmpty(const Utils::SmallStringVector &textVector) const;
|
||||
void checkBindingIntegerVectorIsNotEmpty(const std::vector<int> &integerVector) const;
|
||||
|
||||
Q_NORETURN static void throwException(const char *whatHasHappened, const char *errorMessage);
|
||||
Q_NORETURN static void throwException(const char *whatHasHappened,
|
||||
Utils::SmallString sqlTemplate);
|
||||
|
||||
private:
|
||||
Utils::BasicSmallString<510> m_sqlTemplate;
|
||||
|
||||
@@ -10,7 +10,16 @@ namespace Sqlite {
|
||||
class SQLITE_EXPORT SqlStatementBuilderException : public ExceptionWithMessage
|
||||
{
|
||||
public:
|
||||
using ExceptionWithMessage::ExceptionWithMessage;
|
||||
SqlStatementBuilderException(const char *whatHasHappened,
|
||||
Utils::SmallString &&sqliteErrorMessage)
|
||||
: ExceptionWithMessage(std::move(sqliteErrorMessage))
|
||||
, m_whatHasHappened{whatHasHappened}
|
||||
{}
|
||||
|
||||
const char *what() const noexcept override;
|
||||
|
||||
private:
|
||||
const char *m_whatHasHappened;
|
||||
};
|
||||
|
||||
} // namespace Sqlite
|
||||
|
||||
@@ -203,8 +203,7 @@ TEST_F(SqliteTransaction, ExclusiveTNonThrowingDestructorransactionRollBack)
|
||||
|
||||
TEST_F(SqliteTransaction, DeferredTransactionBeginThrows)
|
||||
{
|
||||
ON_CALL(mockTransactionBackend, deferredBegin())
|
||||
.WillByDefault(Throw(Sqlite::Exception("foo")));
|
||||
ON_CALL(mockTransactionBackend, deferredBegin()).WillByDefault(Throw(Sqlite::Exception()));
|
||||
|
||||
ASSERT_THROW(DeferredTransaction{mockTransactionBackend},
|
||||
Sqlite::Exception);
|
||||
@@ -212,8 +211,7 @@ TEST_F(SqliteTransaction, DeferredTransactionBeginThrows)
|
||||
|
||||
TEST_F(SqliteTransaction, ImmediateTransactionBeginThrows)
|
||||
{
|
||||
ON_CALL(mockTransactionBackend, immediateBegin())
|
||||
.WillByDefault(Throw(Sqlite::Exception("foo")));
|
||||
ON_CALL(mockTransactionBackend, immediateBegin()).WillByDefault(Throw(Sqlite::Exception()));
|
||||
|
||||
ASSERT_THROW(ImmediateTransaction{mockTransactionBackend},
|
||||
Sqlite::Exception);
|
||||
@@ -221,8 +219,7 @@ TEST_F(SqliteTransaction, ImmediateTransactionBeginThrows)
|
||||
|
||||
TEST_F(SqliteTransaction, ExclusiveTransactionBeginThrows)
|
||||
{
|
||||
ON_CALL(mockTransactionBackend, exclusiveBegin())
|
||||
.WillByDefault(Throw(Sqlite::Exception("foo")));
|
||||
ON_CALL(mockTransactionBackend, exclusiveBegin()).WillByDefault(Throw(Sqlite::Exception()));
|
||||
|
||||
ASSERT_THROW(ExclusiveTransaction{mockTransactionBackend},
|
||||
Sqlite::Exception);
|
||||
@@ -233,8 +230,7 @@ TEST_F(SqliteTransaction, DeferredTransactionBeginThrowsAndNotRollback)
|
||||
InSequence s;
|
||||
|
||||
EXPECT_CALL(mockTransactionBackend, lock());
|
||||
EXPECT_CALL(mockTransactionBackend, deferredBegin())
|
||||
.WillOnce(Throw(Sqlite::Exception("foo")));
|
||||
EXPECT_CALL(mockTransactionBackend, deferredBegin()).WillOnce(Throw(Sqlite::Exception()));
|
||||
EXPECT_CALL(mockTransactionBackend, rollback()).Times(0);
|
||||
EXPECT_CALL(mockTransactionBackend, unlock());
|
||||
|
||||
@@ -246,8 +242,7 @@ TEST_F(SqliteTransaction, ImmediateTransactionBeginThrowsAndNotRollback)
|
||||
InSequence s;
|
||||
|
||||
EXPECT_CALL(mockTransactionBackend, lock());
|
||||
EXPECT_CALL(mockTransactionBackend, immediateBegin())
|
||||
.WillOnce(Throw(Sqlite::Exception("foo")));
|
||||
EXPECT_CALL(mockTransactionBackend, immediateBegin()).WillOnce(Throw(Sqlite::Exception()));
|
||||
EXPECT_CALL(mockTransactionBackend, rollback()).Times(0);
|
||||
EXPECT_CALL(mockTransactionBackend, unlock());
|
||||
|
||||
@@ -260,8 +255,7 @@ TEST_F(SqliteTransaction, ExclusiveTransactionBeginThrowsAndNotRollback)
|
||||
InSequence s;
|
||||
|
||||
EXPECT_CALL(mockTransactionBackend, lock());
|
||||
EXPECT_CALL(mockTransactionBackend, exclusiveBegin())
|
||||
.WillOnce(Throw(Sqlite::Exception("foo")));
|
||||
EXPECT_CALL(mockTransactionBackend, exclusiveBegin()).WillOnce(Throw(Sqlite::Exception()));
|
||||
EXPECT_CALL(mockTransactionBackend, rollback()).Times(0);
|
||||
EXPECT_CALL(mockTransactionBackend, unlock());
|
||||
|
||||
@@ -270,8 +264,7 @@ TEST_F(SqliteTransaction, ExclusiveTransactionBeginThrowsAndNotRollback)
|
||||
|
||||
TEST_F(SqliteTransaction, TransactionCommitThrows)
|
||||
{
|
||||
ON_CALL(mockTransactionBackend, commit())
|
||||
.WillByDefault(Throw(Sqlite::Exception("foo")));
|
||||
ON_CALL(mockTransactionBackend, commit()).WillByDefault(Throw(Sqlite::Exception()));
|
||||
ImmediateTransaction transaction{mockTransactionBackend};
|
||||
|
||||
ASSERT_THROW(transaction.commit(),
|
||||
@@ -280,8 +273,7 @@ TEST_F(SqliteTransaction, TransactionCommitThrows)
|
||||
|
||||
TEST_F(SqliteTransaction, TransactionRollbackInDestructorThrows)
|
||||
{
|
||||
ON_CALL(mockTransactionBackend, rollback())
|
||||
.WillByDefault(Throw(Sqlite::Exception("foo")));
|
||||
ON_CALL(mockTransactionBackend, rollback()).WillByDefault(Throw(Sqlite::Exception()));
|
||||
|
||||
ASSERT_THROW(ExclusiveTransaction{mockTransactionBackend},
|
||||
Sqlite::Exception);
|
||||
@@ -289,8 +281,7 @@ TEST_F(SqliteTransaction, TransactionRollbackInDestructorThrows)
|
||||
|
||||
TEST_F(SqliteTransaction, TransactionRollbackInDestructorDontThrows)
|
||||
{
|
||||
ON_CALL(mockTransactionBackend, rollback())
|
||||
.WillByDefault(Throw(Sqlite::Exception("foo")));
|
||||
ON_CALL(mockTransactionBackend, rollback()).WillByDefault(Throw(Sqlite::Exception()));
|
||||
|
||||
ASSERT_NO_THROW(ExclusiveNonThrowingDestructorTransaction{mockTransactionBackend});
|
||||
}
|
||||
@@ -322,15 +313,14 @@ TEST_F(SqliteTransaction, ImmediateSessionTransactionRollBack)
|
||||
|
||||
TEST_F(SqliteTransaction, SessionTransactionRollbackInDestructorThrows)
|
||||
{
|
||||
ON_CALL(mockTransactionBackend, sessionRollback()).WillByDefault(Throw(Sqlite::Exception("foo")));
|
||||
ON_CALL(mockTransactionBackend, sessionRollback()).WillByDefault(Throw(Sqlite::Exception()));
|
||||
|
||||
ASSERT_THROW(ImmediateSessionTransaction{mockTransactionBackend}, Sqlite::Exception);
|
||||
}
|
||||
|
||||
TEST_F(SqliteTransaction, ImmidiateSessionTransactionBeginThrows)
|
||||
{
|
||||
ON_CALL(mockTransactionBackend, immediateSessionBegin())
|
||||
.WillByDefault(Throw(Sqlite::Exception("foo")));
|
||||
ON_CALL(mockTransactionBackend, immediateSessionBegin()).WillByDefault(Throw(Sqlite::Exception()));
|
||||
|
||||
ASSERT_THROW(ImmediateSessionTransaction{mockTransactionBackend}, Sqlite::Exception);
|
||||
}
|
||||
@@ -340,7 +330,7 @@ TEST_F(SqliteTransaction, ImmediateSessionTransactionBeginThrowsAndNotRollback)
|
||||
InSequence s;
|
||||
|
||||
EXPECT_CALL(mockTransactionBackend, lock());
|
||||
EXPECT_CALL(mockTransactionBackend, immediateSessionBegin()).WillOnce(Throw(Sqlite::Exception("foo")));
|
||||
EXPECT_CALL(mockTransactionBackend, immediateSessionBegin()).WillOnce(Throw(Sqlite::Exception()));
|
||||
EXPECT_CALL(mockTransactionBackend, sessionRollback()).Times(0);
|
||||
EXPECT_CALL(mockTransactionBackend, unlock());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user