From 3dcc3ff89f7237bb797aad36021c37f686341954 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Fri, 2 Dec 2022 03:48:16 +1000 Subject: [PATCH] Improve handling of exceptions thrown in `Form.Load` handlers obviously only benefits forms inheriting `FormBase` --- src/BizHawk.Client.EmuHawk/FormBase.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/BizHawk.Client.EmuHawk/FormBase.cs b/src/BizHawk.Client.EmuHawk/FormBase.cs index 950dbee6d0..0ad36d7c95 100644 --- a/src/BizHawk.Client.EmuHawk/FormBase.cs +++ b/src/BizHawk.Client.EmuHawk/FormBase.cs @@ -66,7 +66,17 @@ namespace BizHawk.Client.EmuHawk protected override void OnLoad(EventArgs e) { - base.OnLoad(e); + try + { + base.OnLoad(e); + } + catch (Exception ex) + { + using ExceptionBox box = new(ex); + box.ShowDialog(owner: this); + Close(); + return; + } if (OSTailoredCode.IsUnixHost) FixBackColorOnControls(this); UpdateWindowTitle(); }