File indexing completed on 2024-12-22 04:56:55
0001 /* 0002 SPDX-FileCopyrightText: 2016 Sandro Knauß <sknauss@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "daverror-kdepim-runtime.h" 0008 0009 #include <KLocalizedString> 0010 0011 using namespace KDAV; 0012 0013 QString translateErrorString(const Error &error) 0014 { 0015 QString result; 0016 0017 ErrorNumber errorNumber = error.errorNumber(); 0018 const int responseCode = error.responseCode(); 0019 const QString errorText = error.errorText(); 0020 QString err = error.translatedJobError(); 0021 0022 switch (errorNumber) { 0023 case ERR_PROBLEM_WITH_REQUEST: 0024 // User-side error 0025 if (responseCode == 401) { 0026 err = i18n("Invalid username/password"); 0027 } else if (responseCode == 403) { 0028 err = i18n("Access forbidden"); 0029 } else if (responseCode == 404) { 0030 err = i18n("Resource not found"); 0031 } else { 0032 err = i18n("HTTP error"); 0033 } 0034 result = i18n( 0035 "There was a problem with the request.\n" 0036 "%1 (%2).", 0037 err, 0038 responseCode); 0039 break; 0040 case ERR_NO_MULTIGET: 0041 result = i18n("Protocol for the collection does not support MULTIGET"); 0042 break; 0043 case ERR_SERVER_UNRECOVERABLE: 0044 result = i18n("The server encountered an error that prevented it from completing your request: %1 (%2)", err, responseCode); 0045 break; 0046 case ERR_COLLECTIONDELETE: 0047 result = i18n( 0048 "There was a problem with the request. The collection has not been deleted from the server.\n" 0049 "%1 (%2).", 0050 err, 0051 responseCode); 0052 break; 0053 case ERR_COLLECTIONFETCH: 0054 result = i18n("Invalid responses from backend"); 0055 break; 0056 case ERR_COLLECTIONFETCH_XQUERY_SETFOCUS: 0057 result = i18n("Error setting focus for XQuery"); 0058 break; 0059 case ERR_COLLECTIONFETCH_XQUERY_INVALID: 0060 result = i18n("Invalid XQuery submitted by DAV implementation"); 0061 break; 0062 case ERR_COLLECTIONMODIFY: 0063 result = i18n( 0064 "There was a problem with the request. The collection has not been modified on the server.\n" 0065 "%1 (%2).", 0066 err, 0067 responseCode); 0068 break; 0069 case ERR_COLLECTIONMODIFY_NO_PROPERITES: 0070 result = i18n("No properties to change or remove"); 0071 break; 0072 case ERR_COLLECTIONMODIFY_RESPONSE: 0073 result = i18n("There was an error when modifying the properties"); 0074 if (!errorText.isEmpty()) { 0075 result.append(i18n("\nThe server returned more information:\n%1", errorText)); 0076 } 0077 break; 0078 case ERR_ITEMCREATE: 0079 result = i18n( 0080 "There was a problem with the request. The item has not been created on the server.\n" 0081 "%1 (%2).", 0082 err, 0083 responseCode); 0084 break; 0085 case ERR_ITEMDELETE: 0086 result = i18n( 0087 "There was a problem with the request. The item has not been deleted from the server.\n" 0088 "%1 (%2).", 0089 err, 0090 responseCode); 0091 break; 0092 case ERR_ITEMMODIFY: 0093 result = i18n( 0094 "There was a problem with the request. The item was not modified on the server.\n" 0095 "%1 (%2).", 0096 err, 0097 responseCode); 0098 break; 0099 case ERR_ITEMLIST: { 0100 result = i18n("There was a problem with the request."); 0101 break; 0102 }; 0103 case ERR_ITEMLIST_NOMIMETYPE: 0104 result = i18n("There was a problem with the request. The requested MIME types are not supported."); 0105 break; 0106 case NO_ERR: 0107 break; 0108 } 0109 return result; 0110 }