-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allows us to display a message to the user and quit when an unrecoverable error occurs. Can't really be tested unfortunately.
- Loading branch information
1 parent
d1975db
commit 78d4635
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using UnityEngine; | ||
|
||
namespace ModuleManager | ||
{ | ||
public static class FatalErrorHandler | ||
{ | ||
public static void HandleFatalError(string message) | ||
{ | ||
try | ||
{ | ||
PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), | ||
new Vector2(0.5f, 0.5f), | ||
new MultiOptionDialog( | ||
"ModuleManagerFatalError", | ||
$"ModuleManager has encountered a fatal error and KSP needs to close.\n\n{message}\n\nPlease see KSP's log for addtional details", | ||
"ModuleManager - Fatal Error", | ||
HighLogic.UISkin, | ||
new Rect(0.5f, 0.5f, 500f, 60f), | ||
new DialogGUIFlexibleSpace(), | ||
new DialogGUIHorizontalLayout( | ||
new DialogGUIFlexibleSpace(), | ||
new DialogGUIButton("Quit", Application.Quit, 140.0f, 30.0f, true), | ||
new DialogGUIFlexibleSpace() | ||
) | ||
), | ||
true, | ||
HighLogic.UISkin); | ||
} | ||
catch(Exception ex) | ||
{ | ||
Debug.LogError("Exception while trying to create the fatal exception dialog"); | ||
Debug.LogException(ex); | ||
Application.Quit(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters