File indexing completed on 2024-05-26 05:17:00
0001 /* 0002 Copyright (c) 2016 Sandro Knauß <sknauss@kde.org> 0003 0004 This program is free software; you can redistribute it and/or modify 0005 it under the terms of the GNU General Public License as published by 0006 the Free Software Foundation; either version 2 of the License, or 0007 (at your option) any later version. 0008 0009 This program is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0012 GNU General Public License for more details. 0013 0014 You should have received a copy of the GNU General Public License 0015 along with this program; if not, write to the Free Software 0016 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #ifndef KDAV2_DAVERROR_H 0020 #define KDAV2_DAVERROR_H 0021 0022 #include "kpimkdav2_export.h" 0023 0024 #include <KJob> 0025 0026 #include <QString> 0027 0028 namespace KDAV2 0029 { 0030 0031 enum ErrorNumber { 0032 NO_ERR = 0, 0033 ERR_PROBLEM_WITH_REQUEST = KJob::UserDefinedError + 200, 0034 ERR_NO_MULTIGET, 0035 ERR_SERVER_UNRECOVERABLE, 0036 ERR_COLLECTIONDELETE = ERR_PROBLEM_WITH_REQUEST + 10, 0037 ERR_COLLECTIONFETCH = ERR_PROBLEM_WITH_REQUEST + 20, 0038 ERR_COLLECTIONFETCH_XQUERY_SETFOCUS, 0039 ERR_COLLECTIONFETCH_XQUERY_INVALID, 0040 ERR_COLLECTIONMODIFY = ERR_PROBLEM_WITH_REQUEST + 30, 0041 ERR_COLLECTIONMODIFY_NO_PROPERITES, 0042 ERR_COLLECTIONMODIFY_RESPONSE, 0043 ERR_COLLECTIONCREATE = ERR_PROBLEM_WITH_REQUEST + 40, 0044 ERR_ITEMCREATE = ERR_PROBLEM_WITH_REQUEST + 100, 0045 ERR_ITEMDELETE = ERR_PROBLEM_WITH_REQUEST + 110, 0046 ERR_ITEMMODIFY = ERR_PROBLEM_WITH_REQUEST + 120, 0047 ERR_ITEMLIST = ERR_PROBLEM_WITH_REQUEST + 130, 0048 ERR_ITEMLIST_NOMIMETYPE 0049 }; 0050 0051 class KPIMKDAV2_EXPORT Error { 0052 public: 0053 explicit Error(); 0054 explicit Error(ErrorNumber errNo, int httpStatusCode, int responseCode, const QString &errorText, int jobErrorCode); 0055 0056 /** 0057 * Error number 0058 */ 0059 ErrorNumber errorNumber() const; 0060 0061 /** 0062 * Latest HTTP status code 0063 */ 0064 int httpStatusCode() const; 0065 0066 /** 0067 * Latest QNetworkReply::NetworkError. 0068 */ 0069 int responseCode() const; 0070 0071 /** 0072 * Error text of the subjob that failed. 0073 */ 0074 QString errorText() const; 0075 0076 /** 0077 * Error code of the subjob that failed. 0078 */ 0079 int jobErrorCode() const; 0080 0081 /** 0082 * Generate an error description. 0083 */ 0084 QString description() const; 0085 0086 private: 0087 ErrorNumber mErrorNumber; 0088 int mHttpStatusCode; 0089 int mResponseCode; 0090 QString mErrorText; 0091 int mJobErrorCode; 0092 }; 0093 0094 } 0095 0096 #endif