Fix amiibo timeout issues & log errors/exceptions (#4712)

This commit is contained in:
TSRBerry 2023-04-24 04:08:31 +02:00 committed by GitHub
parent 666e05f5cb
commit c26aeefe03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 11 deletions

View file

@ -1,6 +1,7 @@
using Gtk;
using Ryujinx.Common;
using Ryujinx.Common.Configuration;
using Ryujinx.Common.Logging;
using Ryujinx.Common.Utilities;
using Ryujinx.Ui.Common.Configuration;
using Ryujinx.Ui.Common.Models.Amiibo;
@ -12,7 +13,6 @@ using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using AmiiboApi = Ryujinx.Ui.Common.Models.Amiibo.AmiiboApi;
using AmiiboJsonSerializerContext = Ryujinx.Ui.Common.Models.Amiibo.AmiiboJsonSerializerContext;
@ -57,7 +57,7 @@ namespace Ryujinx.Ui.Windows
_httpClient = new HttpClient()
{
Timeout = TimeSpan.FromMilliseconds(5000)
Timeout = TimeSpan.FromSeconds(30)
};
Directory.CreateDirectory(System.IO.Path.Join(AppDataManager.BaseDirPath, "system", "amiibo"));
@ -93,8 +93,10 @@ namespace Ryujinx.Ui.Windows
{
amiiboJsonString = await DownloadAmiiboJson();
}
catch
catch (Exception ex)
{
Logger.Error?.Print(LogClass.Application, $"Failed to download amiibo data: {ex}");
ShowInfoDialog();
Close();
@ -183,8 +185,10 @@ namespace Ryujinx.Ui.Windows
return false;
}
catch
catch (Exception ex)
{
Logger.Error?.Print(LogClass.Application, $"Failed to check for amiibo updates: {ex}");
ShowInfoDialog();
return false;
@ -208,6 +212,8 @@ namespace Ryujinx.Ui.Windows
}
else
{
Logger.Error?.Print(LogClass.Application, $"Failed to download amiibo data. Response status code: {response.StatusCode}");
GtkDialog.CreateInfoDialog($"Amiibo API", "An error occured while fetching information from the API.");
Close();
@ -233,6 +239,10 @@ namespace Ryujinx.Ui.Windows
_amiiboImage.Pixbuf = amiiboPreview.ScaleSimple(resizeWidth, resizeHeight, Gdk.InterpType.Bilinear);
}
else
{
Logger.Error?.Print(LogClass.Application, $"Failed to get amiibo preview. Response status code: {response.StatusCode}");
}
}
private void ShowInfoDialog()
@ -374,4 +384,4 @@ namespace Ryujinx.Ui.Windows
base.Dispose(disposing);
}
}
}
}