Merge pull request #11903 from peppy/fix-chat-post-error-display

Show API human readable error message when chat posting fails
This commit is contained in:
Dan Balasescu 2021-02-26 19:00:17 +09:00 committed by GitHub
commit e80db89def
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -152,7 +152,7 @@ namespace osu.Game.Online.Chat
createNewPrivateMessageRequest.Failure += exception => createNewPrivateMessageRequest.Failure += exception =>
{ {
Logger.Error(exception, "Posting message failed."); handlePostException(exception);
target.ReplaceMessage(message, null); target.ReplaceMessage(message, null);
dequeueAndRun(); dequeueAndRun();
}; };
@ -171,7 +171,7 @@ namespace osu.Game.Online.Chat
req.Failure += exception => req.Failure += exception =>
{ {
Logger.Error(exception, "Posting message failed."); handlePostException(exception);
target.ReplaceMessage(message, null); target.ReplaceMessage(message, null);
dequeueAndRun(); dequeueAndRun();
}; };
@ -184,6 +184,14 @@ namespace osu.Game.Online.Chat
dequeueAndRun(); dequeueAndRun();
} }
private static void handlePostException(Exception exception)
{
if (exception is APIException apiException)
Logger.Log(apiException.Message, level: LogLevel.Important);
else
Logger.Error(exception, "Posting message failed.");
}
/// <summary> /// <summary>
/// Posts a command locally. Commands like /help will result in a help message written in the current channel. /// Posts a command locally. Commands like /help will result in a help message written in the current channel.
/// </summary> /// </summary>