KDb

KDbError.h
1/* This file is part of the KDE project
2 Copyright (C) 2003 Joseph Wenninger <jowenn@kde.org>
3 Copyright (C) 2003-2016 Jarosław Staniek <staniek@kde.org>
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef _KEXI_ERROR_H_
22#define _KEXI_ERROR_H_
23
24#include <QString>
25#include <QSharedData>
26
27#include "kdb_export.h"
28
29namespace KDb {
30
31/*! Fine-grained KDb error codes */
32
33#define ERR_NONE 0
34#define ERR_NO_NAME_SPECIFIED 9 //! used when name (e.g. for database) was not specified
35#define ERR_DRIVERMANAGER 10
36#define ERR_INVALID_IDENTIFIER 11 //! used when name (e.g. for database) was not specified
37#define ERR_INVALID_ENCODING 12
38#define ERR_MISSING_DB_LOCATION 20
39#define ERR_ALREADY_CONNECTED 30
40#define ERR_NO_CONNECTION 40 //!< when opened connection was expected using KDbConnection
41#define ERR_CONNECTION_FAILED 41 //!< when connection has failed
42#define ERR_CLOSE_FAILED 42 //!< when closing has failed
43#define ERR_NO_DB_USED 43 //!< when used database was expected in KDbConnection
44#define ERR_OBJECT_EXISTS 50
45#define ERR_OBJECT_THE_SAME 51
46#define ERR_OBJECT_NOT_FOUND 60
47#define ERR_CANNOT_LOAD_OBJECT 61
48#define ERR_ACCESS_RIGHTS 70
49#define ERR_TRANSACTION_ACTIVE 80
50#define ERR_NO_TRANSACTION_ACTIVE 81
51#define ERR_NO_DB_PROPERTY 90 //! database property not found, see KDbProperties class
52#define ERR_DB_SPECIFIC 100
53#define ERR_CURSOR_NOT_OPEN 110
54#define ERR_SINGLE_DB_NAME_MISMATCH 120
55#define ERR_CURSOR_RECORD_FETCHING 130 //!< eg. for KDbCursor::drv_getNextRecord()
56#define ERR_UNSUPPORTED_DRV_FEATURE 140 //!< given driver's feature is unsupported (eg. transactins)
57#define ERR_ROLLBACK_OR_COMMIT_TRANSACTION 150 //!< error during transaction rollback or commit
58#define ERR_SYSTEM_NAME_RESERVED 160 //!< system name is reserved and cannot be used
59//!< (e.g. for table, db, or field name)
60#define ERR_CANNOT_CREATE_EMPTY_OBJECT 170 //!< empty object cannot be created
61//!< (e.g. table without fields)
62#define ERR_INVALID_DRIVER_IMPL 180 //! driver's implementation is invalid
63#define ERR_INCOMPAT_DRIVER_VERSION 181 //!< driver's version is incompatible
64#define ERR_INCOMPAT_DATABASE_VERSION 182 //!< db's version is incompatible with currently
65//!< used Kexi version
66#define ERR_INVALID_DATABASE_CONTENTS 183 //!< db's contents are invalid
67//!< (e.g. no enough information to open db)
68
69//! errors related to data updating on the server
70#define ERR_UPDATE_NULL_PKEY_FIELD 190 //!< null pkey field on updating
71#define ERR_UPDATE_SERVER_ERROR 191 //!< error @ the server side during data updating
72#define ERR_UPDATE_NO_MASTER_TABLE 192 //!< data could not be edited because there
73//!< is no master table defined
74#define ERR_UPDATE_NO_MASTER_TABLES_PKEY 193 //!< data could not be edited
75//!< because it's master table has
76//!< no primary key defined
77#define ERR_UPDATE_NO_ENTIRE_MASTER_TABLES_PKEY 194 //!< data could not be edited
78//!< because it does not contain entire
79//!< master table's primary key
80
81//! errors related to data inserting on the server
82#define ERR_INSERT_NULL_PKEY_FIELD 220 //!< null pkey field on updating
83#define ERR_INSERT_SERVER_ERROR 221 //!< error @ the server side during data inserting
84#define ERR_INSERT_NO_MASTER_TABLE 222 //!< data could not be inserted because there
85//!< is no master table defined
86#define ERR_INSERT_NO_MASTER_TABLES_PKEY 223 //!< data could not be inserted because master
87//!< table has no primary key defined
88#define ERR_INSERT_NO_ENTIRE_MASTER_TABLES_PKEY 224 //!< data could not be inserted
89//!< because it does not contain entire
90//!< master table's primary key
91
92//! errors related to data deleting on the server
93#define ERR_DELETE_NULL_PKEY_FIELD 250 //!< null pkey field on updating
94#define ERR_DELETE_SERVER_ERROR 251 //!< error @ the server side during data deleting
95#define ERR_DELETE_NO_MASTER_TABLE 252 //!< data could not be deleted because there
96//!< is no master table defined
97#define ERR_DELETE_NO_MASTER_TABLES_PKEY 253 //!< data could not be deleted because master
98//!< table has no primary key defined
99#define ERR_DELETE_NO_ENTIRE_MASTER_TABLES_PKEY 254 //!< data could not be deleted
100//!< because it does not contain entire
101//!< master table's primary key
102
103//! errors related to queries
104#define ERR_SQL_EXECUTION_ERROR 260 //!< general server error for sql statement execution
105//!< usually returned by KDbConnection::executeSql()
106#define ERR_SQL_PARSE_ERROR 270 //!< Parse error coming from arser::parse()
107
108#define ERR_OTHER 0xffff //!< use this if you have not (yet?) the name for given error
109
110} // namespace KDb
111
112/*! This class contains a result information
113 for various data manipulation operations, like cell/row updating/inserting. */
114class KDB_EXPORT KDbResultInfo
115{
116public:
117 inline KDbResultInfo()
118 {
119 }
120
121 /*! Resets information to default values. */
122 void clear();
123
124 bool success = true; //!< result of the operation, true by default
125 bool allowToDiscardChanges = false; //!< True if changes can be discarded, false by default
126 //!< If @c true, additional "Discard changes" message box
127 //!< button can be displayed.
128 QString message; //!< Error message, empty by default
129 QString description; //!< Detailed error description, empty by default
130 int column = -1; //!< Faulty column, -1 (the default) means: there is no faulty column
131};
132
133//! Sends information about result info @a info to debug output @a dbg.
134//! @since 3.1
135KDB_EXPORT QDebug operator<<(QDebug dbg, const KDbResultInfo &info);
136
137#endif
QString description
Detailed error description, empty by default.
Definition KDbError.h:129
QString message
Error message, empty by default.
Definition KDbError.h:128
A database connectivity and creation framework.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:50:01 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.