Include more error messaging for failed image uploads (#4096)
This commit is contained in:
@@ -204,9 +204,32 @@ void uploadImageToNuuls(RawImageData imageData, ChannelPtr channel,
|
|||||||
return Success;
|
return Success;
|
||||||
})
|
})
|
||||||
.onError([channel](NetworkResult result) -> bool {
|
.onError([channel](NetworkResult result) -> bool {
|
||||||
channel->addMessage(makeSystemMessage(
|
auto errorMessage =
|
||||||
QString("An error happened while uploading your image: %1")
|
QString("An error happened while uploading your image: %1")
|
||||||
.arg(result.status())));
|
.arg(result.status());
|
||||||
|
|
||||||
|
// Try to read more information from the result body
|
||||||
|
auto obj = result.parseJson();
|
||||||
|
if (!obj.isEmpty())
|
||||||
|
{
|
||||||
|
auto apiCode = obj.value("code");
|
||||||
|
if (!apiCode.isUndefined())
|
||||||
|
{
|
||||||
|
auto codeString = apiCode.toVariant().toString();
|
||||||
|
codeString.truncate(20);
|
||||||
|
errorMessage += QString(" - code: %1").arg(codeString);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto apiError = obj.value("error").toString();
|
||||||
|
if (!apiError.isEmpty())
|
||||||
|
{
|
||||||
|
apiError.truncate(300);
|
||||||
|
errorMessage +=
|
||||||
|
QString(" - error: %1").arg(apiError.trimmed());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
channel->addMessage(makeSystemMessage(errorMessage));
|
||||||
uploadMutex.unlock();
|
uploadMutex.unlock();
|
||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user