Improve network error messages (#4704)
This commit is contained in:
@@ -390,7 +390,7 @@ void Helix::createClip(QString channelId,
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
switch (result.status())
|
||||
switch (result.status().value_or(0))
|
||||
{
|
||||
case 503: {
|
||||
// Channel has disabled clip-creation, or channel has made cliops only creatable by followers and the user is not a follower (or subscriber)
|
||||
@@ -406,7 +406,7 @@ void Helix::createClip(QString channelId,
|
||||
|
||||
default: {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Failed to create a clip: " << result.status()
|
||||
<< "Failed to create a clip: " << result.formatError()
|
||||
<< result.getData();
|
||||
failureCallback(HelixClipError::Unknown);
|
||||
}
|
||||
@@ -477,7 +477,7 @@ void Helix::createStreamMarker(
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](NetworkResult result) {
|
||||
switch (result.status())
|
||||
switch (result.status().value_or(0))
|
||||
{
|
||||
case 403: {
|
||||
// User isn't a Channel Editor, so he can't create markers
|
||||
@@ -495,7 +495,7 @@ void Helix::createStreamMarker(
|
||||
default: {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Failed to create a stream marker: "
|
||||
<< result.status() << result.getData();
|
||||
<< result.formatError() << result.getData();
|
||||
failureCallback(HelixStreamMarkerError::Unknown);
|
||||
}
|
||||
break;
|
||||
@@ -638,7 +638,7 @@ void Helix::manageAutoModMessages(
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback, msgID, action](NetworkResult result) {
|
||||
switch (result.status())
|
||||
switch (result.status().value_or(0))
|
||||
{
|
||||
case 400: {
|
||||
// Message was already processed
|
||||
@@ -670,7 +670,7 @@ void Helix::manageAutoModMessages(
|
||||
default: {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Failed to manage automod message: " << action
|
||||
<< msgID << result.status() << result.getData();
|
||||
<< msgID << result.formatError() << result.getData();
|
||||
failureCallback(HelixAutoModMessageError::Unknown);
|
||||
}
|
||||
break;
|
||||
@@ -712,7 +712,7 @@ void Helix::getCheermotes(
|
||||
.onError([broadcasterId, failureCallback](NetworkResult result) {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Failed to get cheermotes(broadcaster_id=" << broadcasterId
|
||||
<< "): " << result.status() << result.getData();
|
||||
<< "): " << result.formatError() << result.getData();
|
||||
failureCallback();
|
||||
})
|
||||
.execute();
|
||||
@@ -806,17 +806,24 @@ void Helix::updateUserChatColor(
|
||||
{
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Success result for updating chat color was"
|
||||
<< result.status() << "but we only expected it to be 204";
|
||||
<< result.formatError()
|
||||
<< "but we only expected it to be 204";
|
||||
}
|
||||
|
||||
successCallback();
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
.onError([failureCallback](const auto &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
auto obj = result.parseJson();
|
||||
auto message = obj.value("message").toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 400: {
|
||||
if (message.startsWith("invalid color",
|
||||
@@ -849,7 +856,7 @@ void Helix::updateUserChatColor(
|
||||
default: {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Unhandled error changing user color:"
|
||||
<< result.status() << result.getData() << obj;
|
||||
<< result.formatError() << result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
break;
|
||||
@@ -882,17 +889,24 @@ void Helix::deleteChatMessages(
|
||||
{
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Success result for deleting chat messages was"
|
||||
<< result.status() << "but we only expected it to be 204";
|
||||
<< result.formatError()
|
||||
<< "but we only expected it to be 204";
|
||||
}
|
||||
|
||||
successCallback();
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
.onError([failureCallback](const auto &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
auto obj = result.parseJson();
|
||||
auto message = obj.value("message").toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 404: {
|
||||
// A 404 on this endpoint means message id is invalid or unable to be deleted.
|
||||
@@ -934,7 +948,7 @@ void Helix::deleteChatMessages(
|
||||
default: {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Unhandled error deleting chat messages:"
|
||||
<< result.status() << result.getData() << obj;
|
||||
<< result.formatError() << result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
break;
|
||||
@@ -960,17 +974,24 @@ void Helix::addChannelModerator(
|
||||
{
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Success result for adding a moderator was"
|
||||
<< result.status() << "but we only expected it to be 204";
|
||||
<< result.formatError()
|
||||
<< "but we only expected it to be 204";
|
||||
}
|
||||
|
||||
successCallback();
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
.onError([failureCallback](const auto &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
auto obj = result.parseJson();
|
||||
auto message = obj.value("message").toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 401: {
|
||||
if (message.startsWith("Missing scope",
|
||||
@@ -1022,7 +1043,7 @@ void Helix::addChannelModerator(
|
||||
default: {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Unhandled error adding channel moderator:"
|
||||
<< result.status() << result.getData() << obj;
|
||||
<< result.formatError() << result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
break;
|
||||
@@ -1048,17 +1069,24 @@ void Helix::removeChannelModerator(
|
||||
{
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Success result for unmodding user was"
|
||||
<< result.status() << "but we only expected it to be 204";
|
||||
<< result.formatError()
|
||||
<< "but we only expected it to be 204";
|
||||
}
|
||||
|
||||
successCallback();
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
.onError([failureCallback](const auto &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
auto obj = result.parseJson();
|
||||
auto message = obj.value("message").toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 400: {
|
||||
if (message.compare("user is not a mod",
|
||||
@@ -1100,8 +1128,8 @@ void Helix::removeChannelModerator(
|
||||
|
||||
default: {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Unhandled error unmodding user:" << result.status()
|
||||
<< result.getData() << obj;
|
||||
<< "Unhandled error unmodding user:"
|
||||
<< result.formatError() << result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
break;
|
||||
@@ -1135,17 +1163,24 @@ void Helix::sendChatAnnouncement(
|
||||
{
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Success result for sending an announcement was"
|
||||
<< result.status() << "but we only expected it to be 204";
|
||||
<< result.formatError()
|
||||
<< "but we only expected it to be 204";
|
||||
}
|
||||
|
||||
successCallback();
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
.onError([failureCallback](const auto &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
auto obj = result.parseJson();
|
||||
auto message = obj.value("message").toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 400: {
|
||||
// These errors are generally well formatted, so we just forward them.
|
||||
@@ -1178,7 +1213,7 @@ void Helix::sendChatAnnouncement(
|
||||
default: {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Unhandled error sending an announcement:"
|
||||
<< result.status() << result.getData() << obj;
|
||||
<< result.formatError() << result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
break;
|
||||
@@ -1204,17 +1239,24 @@ void Helix::addChannelVIP(
|
||||
{
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Success result for adding channel VIP was"
|
||||
<< result.status() << "but we only expected it to be 204";
|
||||
<< result.formatError()
|
||||
<< "but we only expected it to be 204";
|
||||
}
|
||||
|
||||
successCallback();
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
.onError([failureCallback](const auto &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
auto obj = result.parseJson();
|
||||
auto message = obj.value("message").toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 400:
|
||||
case 409:
|
||||
@@ -1256,7 +1298,7 @@ void Helix::addChannelVIP(
|
||||
default: {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Unhandled error adding channel VIP:"
|
||||
<< result.status() << result.getData() << obj;
|
||||
<< result.formatError() << result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
break;
|
||||
@@ -1282,17 +1324,24 @@ void Helix::removeChannelVIP(
|
||||
{
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Success result for removing channel VIP was"
|
||||
<< result.status() << "but we only expected it to be 204";
|
||||
<< result.formatError()
|
||||
<< "but we only expected it to be 204";
|
||||
}
|
||||
|
||||
successCallback();
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
.onError([failureCallback](const auto &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
auto obj = result.parseJson();
|
||||
auto message = obj.value("message").toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 400:
|
||||
case 409:
|
||||
@@ -1333,7 +1382,7 @@ void Helix::removeChannelVIP(
|
||||
default: {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Unhandled error removing channel VIP:"
|
||||
<< result.status() << result.getData() << obj;
|
||||
<< result.formatError() << result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
break;
|
||||
@@ -1371,17 +1420,24 @@ void Helix::unbanUser(
|
||||
{
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Success result for unbanning user was"
|
||||
<< result.status() << "but we only expected it to be 204";
|
||||
<< result.formatError()
|
||||
<< "but we only expected it to be 204";
|
||||
}
|
||||
|
||||
successCallback();
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
.onError([failureCallback](const auto &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
auto obj = result.parseJson();
|
||||
auto message = obj.value("message").toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 400: {
|
||||
if (message.startsWith("The user in the user_id query "
|
||||
@@ -1437,8 +1493,8 @@ void Helix::unbanUser(
|
||||
|
||||
default: {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Unhandled error unbanning user:" << result.status()
|
||||
<< result.getData() << obj;
|
||||
<< "Unhandled error unbanning user:"
|
||||
<< result.formatError() << result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
break;
|
||||
@@ -1476,11 +1532,17 @@ void Helix::startRaid(
|
||||
successCallback();
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
.onError([failureCallback](const auto &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
auto obj = result.parseJson();
|
||||
auto message = obj.value("message").toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 400: {
|
||||
if (message.compare("The IDs in from_broadcaster_id and "
|
||||
@@ -1531,7 +1593,7 @@ void Helix::startRaid(
|
||||
default: {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Unhandled error while starting a raid:"
|
||||
<< result.status() << result.getData() << obj;
|
||||
<< result.formatError() << result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
break;
|
||||
@@ -1556,17 +1618,24 @@ void Helix::cancelRaid(
|
||||
{
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Success result for canceling the raid was"
|
||||
<< result.status() << "but we only expected it to be 204";
|
||||
<< result.formatError()
|
||||
<< "but we only expected it to be 204";
|
||||
}
|
||||
|
||||
successCallback();
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
.onError([failureCallback](const auto &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
auto obj = result.parseJson();
|
||||
auto message = obj.value("message").toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 401: {
|
||||
if (message.startsWith("Missing scope",
|
||||
@@ -1603,7 +1672,7 @@ void Helix::cancelRaid(
|
||||
default: {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Unhandled error while canceling the raid:"
|
||||
<< result.status() << result.getData() << obj;
|
||||
<< result.formatError() << result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
break;
|
||||
@@ -1717,18 +1786,24 @@ void Helix::updateChatSettings(
|
||||
{
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Success result for updating chat settings was"
|
||||
<< result.status() << "but we expected it to be 200";
|
||||
<< result.formatError() << "but we expected it to be 200";
|
||||
}
|
||||
auto response = result.parseJson();
|
||||
successCallback(HelixChatSettings(
|
||||
response.value("data").toArray().first().toObject()));
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
.onError([failureCallback](const auto &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
auto obj = result.parseJson();
|
||||
auto message = obj.value("message").toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 400: {
|
||||
if (message.contains("must be in the range"))
|
||||
@@ -1775,7 +1850,7 @@ void Helix::updateChatSettings(
|
||||
default: {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Unhandled error updating chat settings:"
|
||||
<< result.status() << result.getData() << obj;
|
||||
<< result.formatError() << result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
break;
|
||||
@@ -1840,18 +1915,24 @@ void Helix::fetchChatters(
|
||||
{
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Success result for getting chatters was "
|
||||
<< result.status() << "but we expected it to be 200";
|
||||
<< result.formatError() << "but we expected it to be 200";
|
||||
}
|
||||
|
||||
auto response = result.parseJson();
|
||||
successCallback(HelixChatters(response));
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
.onError([failureCallback](const auto &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
auto obj = result.parseJson();
|
||||
auto message = obj.value("message").toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 400: {
|
||||
failureCallback(Error::Forwarded, message);
|
||||
@@ -1882,7 +1963,7 @@ void Helix::fetchChatters(
|
||||
|
||||
default: {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Unhandled error data:" << result.status()
|
||||
<< "Unhandled error data:" << result.formatError()
|
||||
<< result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
@@ -1949,18 +2030,24 @@ void Helix::fetchModerators(
|
||||
{
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Success result for getting moderators was "
|
||||
<< result.status() << "but we expected it to be 200";
|
||||
<< result.formatError() << "but we expected it to be 200";
|
||||
}
|
||||
|
||||
auto response = result.parseJson();
|
||||
successCallback(HelixModerators(response));
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
.onError([failureCallback](const auto &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
auto obj = result.parseJson();
|
||||
auto message = obj.value("message").toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 400: {
|
||||
failureCallback(Error::Forwarded, message);
|
||||
@@ -1991,7 +2078,7 @@ void Helix::fetchModerators(
|
||||
|
||||
default: {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Unhandled error data:" << result.status()
|
||||
<< "Unhandled error data:" << result.formatError()
|
||||
<< result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
@@ -2035,17 +2122,23 @@ void Helix::banUser(QString broadcasterID, QString moderatorID, QString userID,
|
||||
{
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Success result for banning a user was"
|
||||
<< result.status() << "but we expected it to be 200";
|
||||
<< result.formatError() << "but we expected it to be 200";
|
||||
}
|
||||
// we don't care about the response
|
||||
successCallback();
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
.onError([failureCallback](const auto &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
auto obj = result.parseJson();
|
||||
auto message = obj.value("message").toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 400: {
|
||||
if (message.startsWith("The user specified in the user_id "
|
||||
@@ -2099,8 +2192,8 @@ void Helix::banUser(QString broadcasterID, QString moderatorID, QString userID,
|
||||
|
||||
default: {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Unhandled error banning user:" << result.status()
|
||||
<< result.getData() << obj;
|
||||
<< "Unhandled error banning user:"
|
||||
<< result.formatError() << result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
break;
|
||||
@@ -2132,17 +2225,23 @@ void Helix::sendWhisper(
|
||||
{
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Success result for sending a whisper was"
|
||||
<< result.status() << "but we expected it to be 204";
|
||||
<< result.formatError() << "but we expected it to be 204";
|
||||
}
|
||||
// we don't care about the response
|
||||
successCallback();
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
.onError([failureCallback](const auto &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
auto obj = result.parseJson();
|
||||
auto message = obj.value("message").toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 400: {
|
||||
if (message.startsWith("A user cannot whisper themself",
|
||||
@@ -2203,8 +2302,8 @@ void Helix::sendWhisper(
|
||||
|
||||
default: {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Unhandled error banning user:" << result.status()
|
||||
<< result.getData() << obj;
|
||||
<< "Unhandled error banning user:"
|
||||
<< result.formatError() << result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
break;
|
||||
@@ -2274,8 +2373,8 @@ void Helix::getChannelVIPs(
|
||||
if (result.status() != 200)
|
||||
{
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Success result for getting VIPs was" << result.status()
|
||||
<< "but we expected it to be 200";
|
||||
<< "Success result for getting VIPs was"
|
||||
<< result.formatError() << "but we expected it to be 200";
|
||||
}
|
||||
|
||||
auto response = result.parseJson();
|
||||
@@ -2289,11 +2388,17 @@ void Helix::getChannelVIPs(
|
||||
successCallback(channelVips);
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
.onError([failureCallback](const auto &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
auto obj = result.parseJson();
|
||||
auto message = obj.value("message").toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 400: {
|
||||
failureCallback(Error::Forwarded, message);
|
||||
@@ -2333,8 +2438,8 @@ void Helix::getChannelVIPs(
|
||||
|
||||
default: {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Unhandled error listing VIPs:" << result.status()
|
||||
<< result.getData() << obj;
|
||||
<< "Unhandled error listing VIPs:"
|
||||
<< result.formatError() << result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
break;
|
||||
@@ -2370,11 +2475,17 @@ void Helix::startCommercial(
|
||||
successCallback(HelixStartCommercialResponse(obj));
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
.onError([failureCallback](const auto &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
auto obj = result.parseJson();
|
||||
auto message = obj.value("message").toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 400: {
|
||||
if (message.startsWith("Missing scope",
|
||||
@@ -2429,7 +2540,7 @@ void Helix::startCommercial(
|
||||
default: {
|
||||
qCDebug(chatterinoTwitch)
|
||||
<< "Unhandled error starting commercial:"
|
||||
<< result.status() << result.getData() << obj;
|
||||
<< result.formatError() << result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
break;
|
||||
@@ -2452,18 +2563,24 @@ void Helix::getGlobalBadges(
|
||||
{
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Success result for getting global badges was "
|
||||
<< result.status() << "but we expected it to be 200";
|
||||
<< result.formatError() << "but we expected it to be 200";
|
||||
}
|
||||
|
||||
auto response = result.parseJson();
|
||||
successCallback(HelixGlobalBadges(response));
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
.onError([failureCallback](const auto &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
auto obj = result.parseJson();
|
||||
auto message = obj.value("message").toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 401: {
|
||||
failureCallback(Error::Forwarded, message);
|
||||
@@ -2473,7 +2590,7 @@ void Helix::getGlobalBadges(
|
||||
default: {
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Helix global badges, unhandled error data:"
|
||||
<< result.status() << result.getData() << obj;
|
||||
<< result.formatError() << result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
break;
|
||||
@@ -2499,18 +2616,24 @@ void Helix::getChannelBadges(
|
||||
{
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Success result for getting badges was "
|
||||
<< result.status() << "but we expected it to be 200";
|
||||
<< result.formatError() << "but we expected it to be 200";
|
||||
}
|
||||
|
||||
auto response = result.parseJson();
|
||||
successCallback(HelixChannelBadges(response));
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
.onError([failureCallback](const auto &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
auto obj = result.parseJson();
|
||||
auto message = obj.value("message").toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 400:
|
||||
case 401: {
|
||||
@@ -2521,7 +2644,7 @@ void Helix::getChannelBadges(
|
||||
default: {
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Helix channel badges, unhandled error data:"
|
||||
<< result.status() << result.getData() << obj;
|
||||
<< result.formatError() << result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
break;
|
||||
@@ -2552,7 +2675,7 @@ void Helix::updateShieldMode(
|
||||
{
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Success result for updating shield mode was "
|
||||
<< result.status() << "but we expected it to be 200";
|
||||
<< result.formatError() << "but we expected it to be 200";
|
||||
}
|
||||
|
||||
const auto response = result.parseJson();
|
||||
@@ -2560,11 +2683,17 @@ void Helix::updateShieldMode(
|
||||
HelixShieldModeStatus(response["data"][0].toObject()));
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
.onError([failureCallback](const auto &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
const auto obj = result.parseJson();
|
||||
auto message = obj["message"].toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 400: {
|
||||
if (message.startsWith("Missing scope",
|
||||
@@ -2590,7 +2719,7 @@ void Helix::updateShieldMode(
|
||||
default: {
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Helix shield mode, unhandled error data:"
|
||||
<< result.status() << result.getData() << obj;
|
||||
<< result.formatError() << result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
break;
|
||||
@@ -2619,17 +2748,23 @@ void Helix::sendShoutout(
|
||||
{
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Success result for sending shoutout was "
|
||||
<< result.status() << "but we expected it to be 204";
|
||||
<< result.formatError() << "but we expected it to be 204";
|
||||
}
|
||||
|
||||
successCallback();
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](NetworkResult result) -> void {
|
||||
.onError([failureCallback](const NetworkResult &result) -> void {
|
||||
if (!result.status())
|
||||
{
|
||||
failureCallback(Error::Unknown, result.formatError());
|
||||
return;
|
||||
}
|
||||
|
||||
const auto obj = result.parseJson();
|
||||
auto message = obj["message"].toString();
|
||||
|
||||
switch (result.status())
|
||||
switch (*result.status())
|
||||
{
|
||||
case 400: {
|
||||
if (message.startsWith("The broadcaster may not give "
|
||||
@@ -2692,7 +2827,7 @@ void Helix::sendShoutout(
|
||||
default: {
|
||||
qCWarning(chatterinoTwitch)
|
||||
<< "Helix send shoutout, unhandled error data:"
|
||||
<< result.status() << result.getData() << obj;
|
||||
<< result.formatError() << result.getData() << obj;
|
||||
failureCallback(Error::Unknown, message);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user