diff --git a/AM2RLauncher/AM2RLauncher/Language/Text.Designer.cs b/AM2RLauncher/AM2RLauncher/Language/Text.Designer.cs index b638895..5bcdad7 100644 --- a/AM2RLauncher/AM2RLauncher/Language/Text.Designer.cs +++ b/AM2RLauncher/AM2RLauncher/Language/Text.Designer.cs @@ -207,6 +207,12 @@ namespace AM2RLauncher.Language { } } + public static string GameLaunchFailed { + get { + return ResourceManager.GetString("GameLaunchFailed", resourceCulture); + } + } + public static string GithubToolTip { get { return ResourceManager.GetString("GithubToolTip", resourceCulture); diff --git a/AM2RLauncher/AM2RLauncher/Language/Text.resx b/AM2RLauncher/AM2RLauncher/Language/Text.resx index f993610..c36fff5 100644 --- a/AM2RLauncher/AM2RLauncher/Language/Text.resx +++ b/AM2RLauncher/AM2RLauncher/Language/Text.resx @@ -198,6 +198,9 @@ Error + + The game failed to launch. + The Community-Developers GitHub Page diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs index e5a3e23..ab85a88 100644 --- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs +++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs @@ -469,7 +469,8 @@ public partial class MainForm : Form } catch (Exception ex) { - MessageBox.Show($"{Text.UnhandledException}\n*****Stack Trace*****\n\n{ex}", Text.ErrorWindowTitle, MessageBoxType.Error); + log.Error(ex.Message); + MessageBox.Show($"{Text.GameLaunchFailed}\n\n{ex.Message}", Text.ErrorWindowTitle, MessageBoxType.Error); } ShowInTaskbar = true; diff --git a/AM2RLauncher/AM2RLauncherLib/Profile.cs b/AM2RLauncher/AM2RLauncherLib/Profile.cs index fc116d8..8b5818c 100644 --- a/AM2RLauncher/AM2RLauncherLib/Profile.cs +++ b/AM2RLauncher/AM2RLauncherLib/Profile.cs @@ -738,6 +738,7 @@ public static class Profile string gameDirectory = $"{Core.ProfilesPath}/{profile.Name}"; log.Info($"Launching game profile {profile.Name}."); + int exitCode = 0; if (OS.IsWindows) { // Sets the arguments to empty, or to the profiles' logs folder to create time based logs. @@ -777,6 +778,7 @@ public static class Profile process.Start(); Core.SetForegroundWindow(process.MainWindowHandle); process.WaitForExit(); + exitCode = process.ExitCode; } else if (OS.IsLinux) { @@ -847,6 +849,7 @@ public static class Profile process.BeginErrorReadLine(); } process.WaitForExit(); + exitCode = process.ExitCode; } else if (OS.IsMac) { @@ -882,10 +885,19 @@ public static class Profile using Process process = new Process { StartInfo = processStartInfo }; process.Start(); process.WaitForExit(); + exitCode = process.ExitCode; } else log.Error($"{OS.Name} cannot run games!"); log.Info($"Profile {profile.Name} process exited."); + + if (exitCode != 0) + { + string message = $"Game process for profile \"{profile.Name}\" exited with code {exitCode}, it likely failed to launch."; + if (useLogging) + message += $" Check the log file for more details: {logFile}"; + throw new Exception(message); + } } }