Fix error message of requests with callback
This commit is contained in:
parent
c5d3c7745a
commit
5ac40a2924
|
@ -1073,7 +1073,7 @@ void SyncthingConnection::emitError(const QString &message, const QJsonParseErro
|
|||
}
|
||||
|
||||
/*!
|
||||
* \brief Internally called to emit a network error (server replied error code are connection or server could not be reached at all).
|
||||
* \brief Internally called to emit a network error (server replied error code or server could not be reached at all).
|
||||
*/
|
||||
void SyncthingConnection::emitError(const QString &message, SyncthingErrorCategory category, QNetworkReply *reply)
|
||||
{
|
||||
|
@ -1083,6 +1083,19 @@ void SyncthingConnection::emitError(const QString &message, SyncthingErrorCatego
|
|||
emit error(message + reply->errorString(), category, reply->error(), reply->request(), reply->bytesAvailable() ? reply->readAll() : QByteArray());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Internally called to emit a network error for a specific request (server replied error code or server could not be reached at all).
|
||||
* \remarks The \a message is supposed to already contain the error string of the reply.
|
||||
*/
|
||||
void SyncthingConnection::emitError(const QString &message, QNetworkReply *reply)
|
||||
{
|
||||
if (loggingFlags() & SyncthingConnectionLoggingFlags::ApiReplies) {
|
||||
cerr << Phrases::Error << "Syncthing API error: " << message.toLocal8Bit().data() << reply->errorString().toLocal8Bit().data() << endl;
|
||||
}
|
||||
emit error(message, SyncthingErrorCategory::SpecificRequest, reply->error(), reply->request(),
|
||||
reply->bytesAvailable() ? reply->readAll() : QByteArray());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Internally called to emit myIdChanged() signal.
|
||||
*/
|
||||
|
|
|
@ -403,6 +403,7 @@ private Q_SLOTS:
|
|||
void emitNotification(CppUtilities::DateTime when, const QString &message);
|
||||
void emitError(const QString &message, const QJsonParseError &jsonError, QNetworkReply *reply, const QByteArray &response = QByteArray());
|
||||
void emitError(const QString &message, Data::SyncthingErrorCategory category, QNetworkReply *reply);
|
||||
void emitError(const QString &message, QNetworkReply *reply);
|
||||
void emitMyIdChanged(const QString &newId);
|
||||
void emitTildeChanged(const QString &newTilde, const QString &newPathSeparator);
|
||||
void emitDirStatisticsChanged();
|
||||
|
|
|
@ -1724,8 +1724,8 @@ void SyncthingConnection::readBrowse(
|
|||
break;
|
||||
}
|
||||
default:
|
||||
auto errorMessage = tr("Unable to browse \"%1\": ").arg(dirId);
|
||||
emitError(errorMessage, SyncthingErrorCategory::SpecificRequest, reply);
|
||||
auto errorMessage = tr("Unable to browse \"%1\": ").arg(dirId) + reply->errorString();
|
||||
emitError(errorMessage, reply);
|
||||
if (callback) {
|
||||
callback(std::move(items), std::move(errorMessage));
|
||||
}
|
||||
|
@ -1772,8 +1772,8 @@ void SyncthingConnection::readIgnores(const QString &dirId, std::function<void(S
|
|||
break;
|
||||
}
|
||||
default:
|
||||
auto errorMessage = tr("Unable to query ignore patterns of \"%1\": ").arg(dirId);
|
||||
emitError(errorMessage, SyncthingErrorCategory::SpecificRequest, reply);
|
||||
auto errorMessage = tr("Unable to query ignore patterns of \"%1\": ").arg(dirId) + reply->errorString();
|
||||
emitError(errorMessage, reply);
|
||||
if (callback) {
|
||||
callback(std::move(res), std::move(errorMessage));
|
||||
}
|
||||
|
@ -1794,8 +1794,8 @@ void SyncthingConnection::readSetIgnores(const QString &dirId, std::function<voi
|
|||
break;
|
||||
}
|
||||
default:
|
||||
auto errorMessage = tr("Unable to change ignore patterns of \"%1\": ").arg(dirId);
|
||||
emitError(errorMessage, SyncthingErrorCategory::SpecificRequest, reply);
|
||||
auto errorMessage = tr("Unable to change ignore patterns of \"%1\": ").arg(dirId) + reply->errorString();
|
||||
emitError(errorMessage, reply);
|
||||
if (callback) {
|
||||
callback(std::move(errorMessage));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue