From 183be6c31f6f54a0a1b47446f13f4e83c2b9ddab Mon Sep 17 00:00:00 2001 From: Herman Schoenfeld Date: Tue, 29 Dec 2020 16:23:23 +1000 Subject: [PATCH] Refactor unhandled exception handling loop as per review --- Terminal.Gui/Core/Application.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Terminal.Gui/Core/Application.cs b/Terminal.Gui/Core/Application.cs index 8d3911510..7bb1e9486 100644 --- a/Terminal.Gui/Core/Application.cs +++ b/Terminal.Gui/Core/Application.cs @@ -690,24 +690,24 @@ namespace Terminal.Gui { /// Handler for any unhandled exceptions (resumes when returns true, rethrows when null). public static void Run (Toplevel view, Func errorHandler = null) { - while (true) + var resume = true; + while (resume) { - var resume = false; try { + resume = false; var runToken = Begin (view); RunLoop (runToken); End (runToken); - } - catch (Exception error) + } + catch (Exception error) { if (errorHandler == null) + { throw; - resume = errorHandler (error); + } + resume = errorHandler(error); } - if (resume) - continue; - break; } }