Error handling for failed launch

Add proper error handling for instances that fail to launch, so that the launcher doesn't crash
This commit is contained in:
2023-08-02 14:55:51 +02:00
parent 631551259b
commit 3b2c4175fd

View File

@@ -160,8 +160,24 @@ namespace WolfLauncher.core
if (!String.IsNullOrEmpty(instance.settings.javaArgs))
options.JVMArguments = new string[] { instance.settings.javaArgs };
Process process;
// Set up the launcher process
var process = await cmLauncher.CreateProcessAsync(parseLoader(instance), options, checkAndDownload: true);
try
{
process = await cmLauncher.CreateProcessAsync(parseLoader(instance), options, checkAndDownload: true);
} catch (Exception e)
{
MessageBox.Show(e.Message, "Failed to launch instance", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
// Just a safety catch
if (process == null)
{
runningInstance = null;
return;
}
// Setup console relay to log window
process.OutputDataReceived += (s, e) =>