2015-06-01 18:51:55 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:58:39 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2015-06-01 18:51:55 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2015-06-01 18:51:55 +02:00
|
|
|
|
|
|
|
|
#include "sqliteglobal.h"
|
|
|
|
|
|
2017-07-26 16:38:21 +02:00
|
|
|
#include <utils/smallstring.h>
|
2015-06-16 12:38:04 +02:00
|
|
|
|
2020-05-14 16:41:18 +02:00
|
|
|
#include <exception>
|
2020-05-12 12:54:18 +02:00
|
|
|
#include <iostream>
|
|
|
|
|
|
2017-07-26 16:02:24 +02:00
|
|
|
namespace Sqlite {
|
|
|
|
|
|
2020-05-14 16:41:18 +02:00
|
|
|
class SQLITE_EXPORT Exception : public std::exception
|
2015-06-01 18:51:55 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2020-10-27 15:09:25 +01:00
|
|
|
Exception(const char *whatErrorHasHappen)
|
|
|
|
|
: m_whatErrorHasHappen(whatErrorHasHappen)
|
|
|
|
|
{}
|
|
|
|
|
|
2020-05-27 23:48:03 +02:00
|
|
|
const char *what() const noexcept override { return m_whatErrorHasHappen; }
|
2015-06-01 18:51:55 +02:00
|
|
|
|
2021-12-07 16:18:02 +01:00
|
|
|
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))
|
|
|
|
|
{}
|
|
|
|
|
|
2015-06-01 18:51:55 +02:00
|
|
|
void printWarning() const;
|
|
|
|
|
|
|
|
|
|
private:
|
2017-07-26 16:38:21 +02:00
|
|
|
Utils::SmallString m_sqliteErrorMessage;
|
2015-06-01 18:51:55 +02:00
|
|
|
};
|
2017-07-26 16:02:24 +02:00
|
|
|
|
2021-12-07 16:18:02 +01:00
|
|
|
class StatementIsBusy : public ExceptionWithMessage
|
2017-09-18 11:23:09 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using ExceptionWithMessage::ExceptionWithMessage;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class DatabaseIsBusy : public Exception
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
2021-12-07 16:18:02 +01:00
|
|
|
class StatementHasError : public ExceptionWithMessage
|
2017-09-18 11:23:09 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using ExceptionWithMessage::ExceptionWithMessage;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
2021-12-07 16:18:02 +01:00
|
|
|
class StatementIsMisused : public ExceptionWithMessage
|
2017-09-18 11:23:09 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using ExceptionWithMessage::ExceptionWithMessage;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
2020-06-16 00:05:33 +02:00
|
|
|
class InputOutputError : public Exception
|
2017-09-18 11:23:09 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
2018-04-03 14:34:51 +02:00
|
|
|
};
|
|
|
|
|
|
2021-12-07 16:18:02 +01:00
|
|
|
class ConstraintPreventsModification : public ExceptionWithMessage
|
2018-04-03 14:34:51 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using ExceptionWithMessage::ExceptionWithMessage;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class NoValuesToFetch : public Exception
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
2020-05-27 00:09:19 +02:00
|
|
|
class ColumnCountDoesNotMatch : public Exception
|
2017-09-18 11:23:09 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
2021-12-07 16:18:02 +01:00
|
|
|
class BindingIndexIsOutOfRange : public ExceptionWithMessage
|
2017-09-18 11:23:09 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using ExceptionWithMessage::ExceptionWithMessage;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
2017-09-21 11:43:59 +02:00
|
|
|
class WrongBindingName : public Exception
|
2017-09-18 11:23:09 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class DatabaseIsNotOpen : public Exception
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
2021-12-07 16:18:02 +01:00
|
|
|
class DatabaseCannotBeOpened : public ExceptionWithMessage
|
2017-09-18 11:23:09 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using ExceptionWithMessage::ExceptionWithMessage;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class DatabaseFilePathIsEmpty : public DatabaseCannotBeOpened
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using DatabaseCannotBeOpened::DatabaseCannotBeOpened;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class DatabaseIsAlreadyOpen : public DatabaseCannotBeOpened
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using DatabaseCannotBeOpened::DatabaseCannotBeOpened;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class DatabaseCannotBeClosed : public Exception
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class DatabaseIsAlreadyClosed : public DatabaseCannotBeClosed
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using DatabaseCannotBeClosed::DatabaseCannotBeClosed;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
2021-12-07 16:18:02 +01:00
|
|
|
class WrongFilePath : public ExceptionWithMessage
|
2017-09-18 11:23:09 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using ExceptionWithMessage::ExceptionWithMessage;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class PragmaValueNotSet : public Exception
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class NotReadOnlySqlStatement : public Exception
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class NotWriteSqlStatement : public Exception
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class DeadLock : public Exception
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
2021-12-07 16:18:02 +01:00
|
|
|
class UnknowError : public ExceptionWithMessage
|
2017-09-18 11:23:09 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using ExceptionWithMessage::ExceptionWithMessage;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
2021-12-07 16:18:02 +01:00
|
|
|
class BindingTooBig : public ExceptionWithMessage
|
2017-09-18 11:23:09 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using ExceptionWithMessage::ExceptionWithMessage;
|
2017-09-18 11:23:09 +02:00
|
|
|
};
|
|
|
|
|
|
2021-12-07 16:18:02 +01:00
|
|
|
class TooBig : public ExceptionWithMessage
|
2020-06-16 00:05:33 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using ExceptionWithMessage::ExceptionWithMessage;
|
2020-06-16 00:05:33 +02:00
|
|
|
};
|
|
|
|
|
|
2020-04-27 20:01:38 +02:00
|
|
|
class CannotConvert : public Exception
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
2020-04-27 20:01:38 +02:00
|
|
|
};
|
|
|
|
|
|
2020-05-05 14:05:17 +02:00
|
|
|
class ForeignKeyColumnIsNotUnique : public Exception
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
2020-05-05 14:05:17 +02:00
|
|
|
};
|
|
|
|
|
|
2020-05-27 23:48:03 +02:00
|
|
|
class CannotApplyChangeSet : public Exception
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
2020-05-27 23:48:03 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ChangeSetIsMisused : public Exception
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
2020-05-27 23:48:03 +02:00
|
|
|
};
|
|
|
|
|
|
2021-12-07 16:18:02 +01:00
|
|
|
class SchemeChangeError : public ExceptionWithMessage
|
2020-06-16 00:05:33 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using ExceptionWithMessage::ExceptionWithMessage;
|
2020-06-16 00:05:33 +02:00
|
|
|
};
|
|
|
|
|
|
2021-12-07 16:18:02 +01:00
|
|
|
class CannotWriteToReadOnlyConnection : public ExceptionWithMessage
|
2020-06-16 00:05:33 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using ExceptionWithMessage::ExceptionWithMessage;
|
2020-06-16 00:05:33 +02:00
|
|
|
};
|
|
|
|
|
|
2021-12-07 16:18:02 +01:00
|
|
|
class ProtocolError : public ExceptionWithMessage
|
2020-06-16 00:05:33 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using ExceptionWithMessage::ExceptionWithMessage;
|
2020-06-16 00:05:33 +02:00
|
|
|
};
|
|
|
|
|
|
2021-12-07 16:18:02 +01:00
|
|
|
class DatabaseExceedsMaximumFileSize : public ExceptionWithMessage
|
2020-06-16 00:05:33 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using ExceptionWithMessage::ExceptionWithMessage;
|
2020-06-16 00:05:33 +02:00
|
|
|
};
|
|
|
|
|
|
2021-12-07 16:18:02 +01:00
|
|
|
class DataTypeMismatch : public ExceptionWithMessage
|
2020-06-16 00:05:33 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using ExceptionWithMessage::ExceptionWithMessage;
|
2020-06-16 00:05:33 +02:00
|
|
|
};
|
|
|
|
|
|
2021-12-07 16:18:02 +01:00
|
|
|
class ConnectionIsLocked : public ExceptionWithMessage
|
2020-06-16 00:05:33 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using ExceptionWithMessage::ExceptionWithMessage;
|
2020-06-16 00:05:33 +02:00
|
|
|
};
|
|
|
|
|
|
2021-12-07 16:18:02 +01:00
|
|
|
class ExecutionInterrupted : public ExceptionWithMessage
|
2020-06-16 00:05:33 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using ExceptionWithMessage::ExceptionWithMessage;
|
2020-06-16 00:05:33 +02:00
|
|
|
};
|
|
|
|
|
|
2021-12-07 16:18:02 +01:00
|
|
|
class DatabaseIsCorrupt : public ExceptionWithMessage
|
2020-06-16 00:05:33 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using ExceptionWithMessage::ExceptionWithMessage;
|
2020-06-16 00:05:33 +02:00
|
|
|
};
|
|
|
|
|
|
2021-12-07 16:18:02 +01:00
|
|
|
class CannotOpen : public ExceptionWithMessage
|
2020-06-16 00:05:33 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using ExceptionWithMessage::ExceptionWithMessage;
|
2020-06-16 00:05:33 +02:00
|
|
|
};
|
2020-10-27 15:09:25 +01:00
|
|
|
|
|
|
|
|
class CannotCreateChangeSetIterator : public Exception
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
2020-10-27 15:09:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CannotGetChangeSetOperation : public Exception
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
2020-10-27 15:09:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ChangeSetTupleIsOutOfRange : public Exception
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
2020-10-27 15:09:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ChangeSetTupleIsMisused : public Exception
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
2020-10-27 15:09:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class UnknownError : public Exception
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
2020-10-27 15:09:25 +01:00
|
|
|
};
|
|
|
|
|
|
2021-04-29 18:02:31 +02:00
|
|
|
class DatabaseIsNotLocked : public Exception
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-07 16:18:02 +01:00
|
|
|
using Exception::Exception;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class WrongBindingParameterCount : public Exception
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
using Exception::Exception;
|
2021-04-29 18:02:31 +02:00
|
|
|
};
|
|
|
|
|
|
2017-07-26 16:02:24 +02:00
|
|
|
} // namespace Sqlite
|