8#include <KLocalizedString>
21 int mResponseCode = 0;
22 int mJobErrorCode = 0;
32Error::Error(
ErrorNumber errNo,
int responseCode,
const QString &errorText,
int jobErrorCode)
35 d->mErrorNumber = errNo;
36 d->mResponseCode = responseCode;
37 d->mErrorText = errorText;
38 d->mJobErrorCode = jobErrorCode;
41Error::Error(
const Error &) =
default;
42Error::Error(
Error &&) =
default;
43Error::~Error() =
default;
44Error &Error::operator=(
const Error &) =
default;
49 return d->mErrorNumber;
52QString Error::internalErrorText()
const
57int Error::jobErrorCode()
const
59 return d->mJobErrorCode;
62int Error::responseCode()
const
64 return d->mResponseCode;
67QString KDAV::Error::translatedJobError()
const
82 QString err = translatedJobError();
84 switch (d->mErrorNumber) {
85 case ERR_PROBLEM_WITH_REQUEST:
87 if (d->mResponseCode == 401) {
88 err =
i18n(
"Invalid username/password");
89 }
else if (d->mResponseCode == 403) {
90 err =
i18n(
"Access forbidden");
91 }
else if (d->mResponseCode == 404) {
92 err =
i18n(
"Resource not found");
94 err =
i18n(
"HTTP error");
96 result =
i18n(
"There was a problem with the request.\n%1 (%2).", err, d->mResponseCode);
99 result =
i18n(
"Protocol for the collection does not support MULTIGET");
101 case ERR_SERVER_UNRECOVERABLE:
102 result =
i18n(
"The server encountered an error that prevented it from completing your request: %1 (%2)", err, d->mResponseCode);
104 case ERR_COLLECTIONDELETE:
105 result =
i18n(
"There was a problem with the request. The collection has not been deleted from the server.\n%1 (%2).", err, d->mResponseCode);
107 case ERR_COLLECTIONFETCH:
108 result =
i18n(
"Invalid responses from backend");
110 case ERR_COLLECTIONFETCH_XQUERY_SETFOCUS:
111 result =
i18n(
"Error setting focus for XQuery");
113 case ERR_COLLECTIONFETCH_XQUERY_INVALID:
114 result =
i18n(
"Invalid XQuery submitted by DAV implementation");
116 case ERR_COLLECTIONMODIFY:
118 "There was a problem with the request. The collection has not been modified on the server.\n"
123 case ERR_COLLECTIONMODIFY_NO_PROPERITES:
124 result =
i18n(
"No properties to change or remove");
126 case ERR_COLLECTIONMODIFY_RESPONSE:
127 result =
i18n(
"There was an error when modifying the properties");
128 if (!d->mErrorText.isEmpty()) {
129 result.
append(
i18n(
"\nThe server returned more information:\n%1", d->mErrorText));
133 result =
i18n(
"There was a problem with the request. The item has not been created on the server.\n%1 (%2).", err, d->mResponseCode);
136 result =
i18n(
"There was a problem with the request. The item has not been deleted from the server.\n%1 (%2).", err, d->mResponseCode);
139 result =
i18n(
"There was a problem with the request. The item was not modified on the server.\n%1 (%2).", err, d->mResponseCode);
142 result =
i18n(
"There was a problem with the request.");
145 case ERR_ITEMLIST_NOMIMETYPE:
146 result =
i18n(
"There was a problem with the request. The requested MIME types are not supported.");
QString i18n(const char *text, const TYPE &arg...)
ErrorNumber
DAV operation error codes.
KIOCORE_EXPORT QString buildErrorString(int errorCode, const QString &errorText)
QString & append(QChar ch)