mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
feat: add sink fail reason and correctly propagate it through the NetRequest
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
a89fc7d1e0
commit
c3749c4fdc
7 changed files with 36 additions and 8 deletions
|
|
@ -86,6 +86,7 @@ auto ImgurAlbumCreation::Sink::write(QByteArray& data) -> Task::State
|
|||
auto ImgurAlbumCreation::Sink::abort() -> Task::State
|
||||
{
|
||||
m_output.clear();
|
||||
m_fail_reason = "Aborted";
|
||||
return Task::State::Failed;
|
||||
}
|
||||
|
||||
|
|
@ -95,11 +96,13 @@ auto ImgurAlbumCreation::Sink::finalize(QNetworkReply&) -> Task::State
|
|||
QJsonDocument doc = QJsonDocument::fromJson(m_output, &jsonError);
|
||||
if (jsonError.error != QJsonParseError::NoError) {
|
||||
qDebug() << jsonError.errorString();
|
||||
m_fail_reason = "Invalid json reply";
|
||||
return Task::State::Failed;
|
||||
}
|
||||
auto object = doc.object();
|
||||
if (!object.value("success").toBool()) {
|
||||
qDebug() << doc.toJson();
|
||||
m_fail_reason = "Failed to create album";
|
||||
return Task::State::Failed;
|
||||
}
|
||||
m_result->deleteHash = object.value("data").toObject().value("deletehash").toString();
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ auto ImgurUpload::Sink::write(QByteArray& data) -> Task::State
|
|||
auto ImgurUpload::Sink::abort() -> Task::State
|
||||
{
|
||||
m_output.clear();
|
||||
m_fail_reason = "Aborted";
|
||||
return Task::State::Failed;
|
||||
}
|
||||
|
||||
|
|
@ -99,11 +100,13 @@ auto ImgurUpload::Sink::finalize(QNetworkReply&) -> Task::State
|
|||
QJsonDocument doc = QJsonDocument::fromJson(m_output, &jsonError);
|
||||
if (jsonError.error != QJsonParseError::NoError) {
|
||||
qDebug() << "imgur server did not reply with JSON" << jsonError.errorString();
|
||||
m_fail_reason = "Invalid json reply";
|
||||
return Task::State::Failed;
|
||||
}
|
||||
auto object = doc.object();
|
||||
if (!object.value("success").toBool()) {
|
||||
qDebug() << "Screenshot upload not successful:" << doc.toJson();
|
||||
m_fail_reason = "Screenshot was not uploaded successfully";
|
||||
return Task::State::Failed;
|
||||
}
|
||||
m_shot->m_imgurId = object.value("data").toObject().value("id").toString();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue