forked from qt-creator/qt-creator
Axivion: Suppress the network error logging on unauthorized access
This is a valid path to try the unauthorized access first, and when it fails we automatically try the authorized access. So we shouldn't bother the user with an error on a failure on unauthorized access to the dashboard info. Change-Id: Ia27686f804415741da614e36802551f8d8d610ed Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Andreas Loth <andreas.loth@qt.io>
This commit is contained in:
committed by
Christian Stenger
parent
10da1ef3ff
commit
d32a5ebb35
@@ -440,24 +440,31 @@ static Group dtoRecipe(const Storage<DtoStorageType<DtoType>> &dtoStorage)
|
|||||||
return DoneResult::Success;
|
return DoneResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto getError = [&]() -> Error {
|
QString errorString;
|
||||||
if (contentType == s_jsonContentType) {
|
if (contentType == s_jsonContentType) {
|
||||||
try {
|
const Utils::expected_str<Dto::ErrorDto> error
|
||||||
return DashboardError(reply->url(), statusCode,
|
= Dto::ErrorDto::deserializeExpected(reply->readAll());
|
||||||
reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString(),
|
|
||||||
Dto::ErrorDto::deserialize(reply->readAll()));
|
if (error) {
|
||||||
} catch (const Dto::invalid_dto_exception &) {
|
if constexpr (std::is_same_v<DtoType, Dto::DashboardInfoDto>) {
|
||||||
// ignore
|
// Suppress logging error on unauthorized dashboard fetch
|
||||||
|
if (!dtoStorage->credential && error->type == "UnauthenticatedException")
|
||||||
|
return DoneResult::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errorString = Error(DashboardError(reply->url(), statusCode,
|
||||||
|
reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString(),
|
||||||
|
*error)).message();
|
||||||
}
|
}
|
||||||
if (statusCode != 0) {
|
} else if (statusCode != 0) {
|
||||||
return HttpError(reply->url(), statusCode,
|
errorString = Error(HttpError(reply->url(), statusCode,
|
||||||
reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString(),
|
reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toString(),
|
||||||
QString::fromUtf8(reply->readAll())); // encoding?
|
QString::fromUtf8(reply->readAll()))).message(); // encoding?
|
||||||
}
|
} else {
|
||||||
return NetworkError(reply->url(), error, reply->errorString());
|
errorString = Error(NetworkError(reply->url(), error, reply->errorString())).message();
|
||||||
};
|
}
|
||||||
MessageManager::writeDisrupting(QString("Axivion: %1").arg(getError().message()));
|
|
||||||
|
MessageManager::writeDisrupting(QString("Axivion: %1").arg(errorString));
|
||||||
return DoneResult::Error;
|
return DoneResult::Error;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user