summaryrefslogtreecommitdiff
path: root/src/SMAPI.Installer/Program.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Installer/Program.cs')
-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);
+ }
}
}