add unhandled exception handler

This commit is contained in:
emmaus 2019-01-10 22:03:10 +00:00
commit 00f03f99ba
2 changed files with 15 additions and 0 deletions

View file

@ -5,6 +5,7 @@ namespace Ryujinx.Common.Logging
Audio, Audio,
Cpu, Cpu,
Font, Font,
Emulation,
Gpu, Gpu,
Hid, Hid,
Kernel, Kernel,

View file

@ -24,6 +24,8 @@ namespace Ryujinx
Logger.Updated += ConsoleLog.Log; Logger.Updated += ConsoleLog.Log;
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
if (args.Length == 1) if (args.Length == 1)
{ {
if (Directory.Exists(args[0])) if (Directory.Exists(args[0]))
@ -86,6 +88,18 @@ namespace Ryujinx
audioOut.Dispose(); audioOut.Dispose();
} }
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
var exception = e.ExceptionObject as Exception;
Logger.PrintError(LogClass.Emulation, $"Unhandled exception caught: {exception}");
Logger.PrintInfo(LogClass.Emulation,"Press any key to close the application...");
Console.ReadKey();
Environment.Exit(0);
}
/// <summary> /// <summary>
/// Picks an <see cref="IAalOutput"/> audio output renderer supported on this machine /// Picks an <see cref="IAalOutput"/> audio output renderer supported on this machine
/// </summary> /// </summary>