Skip to content

Commit b61199a

Browse files
committed
Fail fast to exit Flow when encountering issue in constructor
1 parent 92df021 commit b61199a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Flow.Launcher/App.xaml.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public App()
4444
}
4545
catch (Exception e)
4646
{
47-
ShowErrorMsgBox("Cannot load setting storage, please check local data directory", e);
47+
ShowErrorMsgBoxAndFailFast("Cannot load setting storage, please check local data directory", e);
4848
return;
4949
}
5050

@@ -69,7 +69,7 @@ public App()
6969
}
7070
catch (Exception e)
7171
{
72-
ShowErrorMsgBox("Cannot configure dependency injection container, please open new issue in Flow.Launcher", e);
72+
ShowErrorMsgBoxAndFailFast("Cannot configure dependency injection container, please open new issue in Flow.Launcher", e);
7373
return;
7474
}
7575

@@ -81,14 +81,18 @@ public App()
8181
}
8282
catch (Exception e)
8383
{
84-
ShowErrorMsgBox("Cannot initialize api and settings, please open new issue in Flow.Launcher", e);
84+
ShowErrorMsgBoxAndFailFast("Cannot initialize api and settings, please open new issue in Flow.Launcher", e);
8585
return;
8686
}
8787
}
8888

89-
private static void ShowErrorMsgBox(string caption, Exception e)
89+
private static void ShowErrorMsgBoxAndFailFast(string message, Exception e)
9090
{
91-
MessageBox.Show(e.ToString(), caption, MessageBoxButton.OK, MessageBoxImage.Error);
91+
// Firstly show users the message
92+
MessageBox.Show(e.ToString(), message, MessageBoxButton.OK, MessageBoxImage.Error);
93+
94+
// Flow cannot construct its App instance, so ensure Flow crashes w/ the exception info.
95+
Environment.FailFast(message, e);
9296
}
9397

9498
[STAThread]

0 commit comments

Comments
 (0)