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; } }