EasyQtSql
Easy SQL data access helper for QtSql
EasyQtSql_DBException.h
Go to the documentation of this file.
1 #ifndef EASYQTSQL_DBEXCEPTION_H
2 #define EASYQTSQL_DBEXCEPTION_H
3 
4 /*
5  * The MIT License (MIT)
6  * Copyright 2018 Alexey Kramin
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26  *
27 */
28 
29 #ifndef EASY_QT_SQL_MAIN
30 
31 #include <QtSql>
32 
33 #endif
34 
38 class DBException : public QException
39 {
40  friend class Database;
41  friend class Transaction;
42  friend class PreparedQuery;
43  friend class InsertQuery;
44  friend class UpdateQuery;
45  friend class DeleteQuery;
46 
47 public:
48  const QSqlError lastError;
49  const QString lastQuery;
50 
51 private:
52  explicit DBException (const QSqlQuery &q)
53  : lastError(q.lastError())
54  , lastQuery(q.lastQuery())
55  { }
56 
57  explicit DBException (const QSqlDatabase &db)
58  : lastError(db.lastError())
59  { }
60 };
61 
62 #endif // EASYQTSQL_DBEXCEPTION_H
const QSqlError lastError
Definition: EasyQtSql_DBException.h:48
Class for query preparation and execution.
Definition: EasyQtSql_PreparedQuery.h:63
const QString lastQuery
Definition: EasyQtSql_DBException.h:49
QSqlDatabase wrapper.
Definition: EasyQtSql_Transaction.h:67
QSqlQuery wrapper for DELETE FROM ... WHERE .. query execution.
Definition: EasyQtSql_DeleteQuery.h:39
QSqlDatabase transaction wrapper.
Definition: EasyQtSql_Transaction.h:398
QSqlQuery wrapper for INSERT INTO table query execution.
Definition: EasyQtSql_InsertQuery.h:39
QSqlQuery wrapper for UPDATE ... SET ... WHERE ... query execution.
Definition: EasyQtSql_UpdateQuery.h:39
Exception class for SQL errors handling.
Definition: EasyQtSql_DBException.h:38