File indexing completed on 2022-11-29 19:02:23

0001 /* This file is part of the KDE project
0002    Copyright (C) 2003 Joseph Wenninger <jowenn@kde.org>
0003    Copyright (C) 2003-2016 Jarosław Staniek <staniek@kde.org>
0004 
0005    This program is free software; you can redistribute it and/or
0006    modify it under the terms of the GNU Library General Public
0007    License as published by the Free Software Foundation; either
0008    version 2 of the License, or (at your option) any later version.
0009 
0010    This program is distributed in the hope that it will be useful,
0011    but WITHOUT ANY WARRANTY; without even the implied warranty of
0012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013    Library General Public License for more details.
0014 
0015    You should have received a copy of the GNU Library General Public License
0016    along with this program; see the file COPYING.  If not, write to
0017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019 */
0020 
0021 #ifndef _KEXI_ERROR_H_
0022 #define _KEXI_ERROR_H_
0023 
0024 #include <QString>
0025 #include <QSharedData>
0026 
0027 #include "kdb_export.h"
0028 
0029 namespace KDb {
0030 
0031 /*! Fine-grained KDb error codes */
0032 
0033 #define ERR_NONE 0
0034 #define ERR_NO_NAME_SPECIFIED 9 //! used when name (e.g. for database) was not specified
0035 #define ERR_DRIVERMANAGER 10
0036 #define ERR_INVALID_IDENTIFIER 11 //! used when name (e.g. for database) was not specified
0037 #define ERR_INVALID_ENCODING 12
0038 #define ERR_MISSING_DB_LOCATION 20
0039 #define ERR_ALREADY_CONNECTED 30
0040 #define ERR_NO_CONNECTION 40 //!< when opened connection was expected using KDbConnection
0041 #define ERR_CONNECTION_FAILED 41 //!< when connection has failed
0042 #define ERR_CLOSE_FAILED 42 //!< when closing has failed
0043 #define ERR_NO_DB_USED 43 //!< when used database was expected in KDbConnection
0044 #define ERR_OBJECT_EXISTS 50
0045 #define ERR_OBJECT_THE_SAME 51
0046 #define ERR_OBJECT_NOT_FOUND 60
0047 #define ERR_CANNOT_LOAD_OBJECT 61
0048 #define ERR_ACCESS_RIGHTS 70
0049 #define ERR_TRANSACTION_ACTIVE 80
0050 #define ERR_NO_TRANSACTION_ACTIVE 81
0051 #define ERR_NO_DB_PROPERTY 90 //! database property not found, see KDbProperties class
0052 #define ERR_DB_SPECIFIC 100
0053 #define ERR_CURSOR_NOT_OPEN 110
0054 #define ERR_SINGLE_DB_NAME_MISMATCH 120
0055 #define ERR_CURSOR_RECORD_FETCHING 130 //!< eg. for KDbCursor::drv_getNextRecord()
0056 #define ERR_UNSUPPORTED_DRV_FEATURE 140 //!< given driver's feature is unsupported (eg. transactins)
0057 #define ERR_ROLLBACK_OR_COMMIT_TRANSACTION 150 //!< error during transaction rollback or commit
0058 #define ERR_SYSTEM_NAME_RESERVED 160 //!< system name is reserved and cannot be used
0059 //!< (e.g. for table, db, or field name)
0060 #define ERR_CANNOT_CREATE_EMPTY_OBJECT 170 //!< empty object cannot be created
0061 //!< (e.g. table without fields)
0062 #define ERR_INVALID_DRIVER_IMPL 180 //! driver's implementation is invalid
0063 #define ERR_INCOMPAT_DRIVER_VERSION 181 //!< driver's version is incompatible
0064 #define ERR_INCOMPAT_DATABASE_VERSION 182 //!< db's version is incompatible with currently
0065 //!< used Kexi version
0066 #define ERR_INVALID_DATABASE_CONTENTS 183 //!< db's contents are invalid
0067 //!< (e.g. no enough information to open db)
0068 
0069 //! errors related to data updating on the server
0070 #define ERR_UPDATE_NULL_PKEY_FIELD 190 //!< null pkey field on updating
0071 #define ERR_UPDATE_SERVER_ERROR 191    //!< error @ the server side during data updating
0072 #define ERR_UPDATE_NO_MASTER_TABLE 192 //!< data could not be edited because there
0073 //!< is no master table defined
0074 #define ERR_UPDATE_NO_MASTER_TABLES_PKEY 193 //!< data could not be edited
0075 //!< because it's master table has
0076 //!< no primary key defined
0077 #define ERR_UPDATE_NO_ENTIRE_MASTER_TABLES_PKEY 194 //!< data could not be edited
0078 //!< because it does not contain entire
0079 //!< master table's primary key
0080 
0081 //! errors related to data inserting on the server
0082 #define ERR_INSERT_NULL_PKEY_FIELD 220 //!< null pkey field on updating
0083 #define ERR_INSERT_SERVER_ERROR 221    //!< error @ the server side during data inserting
0084 #define ERR_INSERT_NO_MASTER_TABLE 222 //!< data could not be inserted because there
0085 //!< is no master table defined
0086 #define ERR_INSERT_NO_MASTER_TABLES_PKEY 223 //!< data could not be inserted because master
0087 //!< table has no primary key defined
0088 #define ERR_INSERT_NO_ENTIRE_MASTER_TABLES_PKEY 224 //!< data could not be inserted
0089 //!< because it does not contain entire
0090 //!< master table's primary key
0091 
0092 //! errors related to data deleting on the server
0093 #define ERR_DELETE_NULL_PKEY_FIELD 250 //!< null pkey field on updating
0094 #define ERR_DELETE_SERVER_ERROR 251    //!< error @ the server side during data deleting
0095 #define ERR_DELETE_NO_MASTER_TABLE 252 //!< data could not be deleted because there
0096 //!< is no master table defined
0097 #define ERR_DELETE_NO_MASTER_TABLES_PKEY 253 //!< data could not be deleted because master
0098 //!< table has no primary key defined
0099 #define ERR_DELETE_NO_ENTIRE_MASTER_TABLES_PKEY 254 //!< data could not be deleted
0100 //!< because it does not contain entire
0101 //!< master table's primary key
0102 
0103 //! errors related to queries
0104 #define ERR_SQL_EXECUTION_ERROR 260 //!< general server error for sql statement execution
0105 //!< usually returned by KDbConnection::executeSql()
0106 #define ERR_SQL_PARSE_ERROR 270 //!< Parse error coming from arser::parse()
0107 
0108 #define ERR_OTHER 0xffff //!< use this if you have not (yet?) the name for given error
0109 
0110 } // namespace KDb
0111 
0112 /*! This class contains a result information
0113  for various data manipulation operations, like cell/row updating/inserting. */
0114 class KDB_EXPORT KDbResultInfo
0115 {
0116 public:
0117     inline KDbResultInfo()
0118     {
0119     }
0120 
0121     /*! Resets information to default values. */
0122     void clear();
0123 
0124     bool success = true; //!< result of the operation, true by default
0125     bool allowToDiscardChanges = false; //!< True if changes can be discarded, false by default
0126                                         //!< If @c true, additional "Discard changes" message box
0127                                         //!< button can be displayed.
0128     QString message; //!< Error message, empty by default
0129     QString description; //!< Detailed error description, empty by default
0130     int column = -1; //!< Faulty column, -1 (the default) means: there is no faulty column
0131 };
0132 
0133 //! Sends information about result info @a info to debug output @a dbg.
0134 //! @since 3.1
0135 KDB_EXPORT QDebug operator<<(QDebug dbg, const KDbResultInfo &info);
0136 
0137 #endif