-
-
Notifications
You must be signed in to change notification settings - Fork 200
Fix invalid notification title in Imgur failed uploads #803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,9 +157,9 @@ void ImgurWrapper::handleDataResponse(const QDomElement& element) const | |
emit tokenRefreshRequired(); | ||
} else { | ||
if (element.elementsByTagName(QLatin1String("error")).isEmpty()) { | ||
emit error(QLatin1String("Server responded with ") + element.attribute(QLatin1String("status"))); | ||
emit error(QNetworkReply::ProtocolFailure, QLatin1String("Server responded with ") + element.attribute(QLatin1String("status"))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pretty sure ProtocolFailure is the best option for these errors. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sound good I think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Though I'm not sure if we should pass the QNetworkReply outside the Warpper. The idea of the wrapper is to hide the implementation, the upload could happen via network or be send via pigeon, the caller shouldn't know about it. Is there a way to not pass this enum outside the the Warpper? Haven't had time to look into it yet, I can check it over the weekend. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't think of another way though 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the code, is the error type that much relevant? In the path with the settings we ignore it completely. From my point of view the issue was |
||
} else { | ||
emit error(QLatin1String("Server responded with ") + element.attribute(QLatin1String("status")) + ": " + | ||
emit error(QNetworkReply::ProtocolFailure, QLatin1String("Server responded with ") + element.attribute(QLatin1String("status")) + ": " + | ||
element.elementsByTagName(QLatin1String("error")).at(0).toElement().text()); | ||
} | ||
} | ||
|
@@ -180,7 +180,7 @@ void ImgurWrapper::handleTokenResponse(const QDomElement& element) const | |
element.elementsByTagName(QLatin1String("account_username")).at(0).toElement().text() | ||
); | ||
} else { | ||
emit error(QLatin1String("Expected token response was received, something went wrong.")); | ||
emit error(QNetworkReply::ProtocolFailure, QLatin1String("Expected token response was received, something went wrong.")); | ||
} | ||
} | ||
|
||
|
@@ -203,7 +203,7 @@ void ImgurWrapper::handleReply(QNetworkReply* reply) | |
// token. | ||
if (reply->error() != QNetworkReply::NoError && | ||
reply->error() != QNetworkReply::ContentOperationNotPermittedError) { | ||
emit error(QLatin1String("Network Error(") + QString::number(reply->error()) + "): " + reply->errorString()); | ||
emit error(reply->error(), QLatin1String("Network Error(") + QString::number(reply->error()) + "): " + reply->errorString()); | ||
reply->deleteLater(); | ||
return; | ||
} | ||
|
@@ -213,13 +213,14 @@ void ImgurWrapper::handleReply(QNetworkReply* reply) | |
int errorLine; | ||
int errorColumn; | ||
|
||
// Try to parse reply into xml reader | ||
if (!doc.setContent(reply->readAll(), false, &errorMessage, &errorLine, &errorColumn)) { | ||
emit error(QLatin1String("Parse error: ") + errorMessage + QLatin1String(", line:") + errorLine + | ||
QLatin1String(", column:") + errorColumn); | ||
reply->deleteLater(); | ||
return; | ||
} | ||
// Try to parse reply into xml reader | ||
if (!doc.setContent(reply->readAll(), false, &errorMessage, &errorLine, &errorColumn)) { | ||
emit error(QNetworkReply::ProtocolFailure, | ||
QLatin1String("Parse error: ") + errorMessage + QLatin1String(", line:") + errorLine + | ||
QLatin1String(", column:") + errorColumn); | ||
reply->deleteLater(); | ||
return; | ||
} | ||
|
||
// See if we have an upload reply, token response or error | ||
auto rootElement = doc.documentElement(); | ||
|
@@ -229,9 +230,8 @@ void ImgurWrapper::handleReply(QNetworkReply* reply) | |
} else if (rootElement.tagName() == QLatin1String("response")) { | ||
handleTokenResponse(rootElement); | ||
} | ||
|
||
else { | ||
emit error(QLatin1String("Received unexpected reply from imgur server.")); | ||
emit error(QNetworkReply::ProtocolFailure, QLatin1String("Received unexpected reply from imgur server.")); | ||
} | ||
|
||
reply->deleteLater(); | ||
|
Uh oh!
There was an error while loading. Please reload this page.