From 0eb7bf7a4bc1c9221a48970e2b0b83268bdfb0e7 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 28 Nov 2020 14:53:32 -0800 Subject: [PATCH] Add alert if database load fails Task is executed without reporting exceptions; continue after the task with another that checks if it failed. --- PKHeX.WinForms/Subforms/SAV_Database.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/PKHeX.WinForms/Subforms/SAV_Database.cs b/PKHeX.WinForms/Subforms/SAV_Database.cs index c70aaeb63..31ac1ba0a 100644 --- a/PKHeX.WinForms/Subforms/SAV_Database.cs +++ b/PKHeX.WinForms/Subforms/SAV_Database.cs @@ -79,7 +79,17 @@ public SAV_Database(PKMEditor f1, SAVEditor saveditor) // Load Data B_Search.Enabled = false; L_Count.Text = "Loading..."; - new Task(LoadDatabase).Start(); + var task = new Task(LoadDatabase); + task.ContinueWith(z => + { + if (!z.IsFaulted) + return; + Invoke((MethodInvoker)(() => L_Count.Text = "Failed.")); + if (z.Exception == null) + return; + WinFormsUtil.Error("Loading database failed.", z.Exception.InnerException ?? new Exception(z.Exception.Message)); + }); + task.Start(); Menu_SearchSettings.DropDown.Closing += (sender, e) => {