summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-03-07 17:42:55 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-03-07 17:42:55 -0500
commit36cb8e8fcb8afd2965ffe26e7755eb11838264d7 (patch)
treee3843446df19c1423d4295927f3603e2c94de7a3 /src
parent5a2258f4194986df3dea7dca9b17cdc96b3e63d5 (diff)
downloadSMAPI-36cb8e8fcb8afd2965ffe26e7755eb11838264d7.tar.gz
SMAPI-36cb8e8fcb8afd2965ffe26e7755eb11838264d7.tar.bz2
SMAPI-36cb8e8fcb8afd2965ffe26e7755eb11838264d7.zip
keep window open when installer crashes
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI.Installer/Program.cs25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/SMAPI.Installer/Program.cs b/src/SMAPI.Installer/Program.cs
index 6c479621..d9c31dd6 100644
--- a/src/SMAPI.Installer/Program.cs
+++ b/src/SMAPI.Installer/Program.cs
@@ -3,6 +3,7 @@ using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.IO.Compression;
using System.Reflection;
+using System.Threading;
namespace StardewModdingApi.Installer
{
@@ -49,7 +50,15 @@ namespace StardewModdingApi.Installer
// launch installer
var installer = new InteractiveInstaller(bundleDir.FullName);
- installer.Run(args);
+
+ try
+ {
+ installer.Run(args);
+ }
+ catch (Exception ex)
+ {
+ Program.PrintErrorAndExit($"The installer failed with an unexpected exception.\nIf you need help fixing this error, see https://smapi.io/help\n\n{ex}");
+ }
}
/*********
@@ -76,5 +85,19 @@ namespace StardewModdingApi.Installer
return null;
}
}
+
+ /// <summary>Write an error directly to the console and exit.</summary>
+ /// <param name="message">The error message to display.</param>
+ private static void PrintErrorAndExit(string message)
+ {
+ Console.ForegroundColor = ConsoleColor.Red;
+ Console.WriteLine(message);
+ Console.ResetColor();
+
+ Console.WriteLine("Game has ended. Press any key to exit.");
+ Thread.Sleep(100);
+ Console.ReadKey();
+ Environment.Exit(0);
+ }
}
}