mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Avoid unhandled exception handlers logging into disposed sawmills on shutdown
This caused a crash & exception swallow on Salamander.
This commit is contained in:
@@ -126,13 +126,29 @@ namespace Robust.Server
|
||||
AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
|
||||
{
|
||||
var message = ((Exception) args.ExceptionObject).ToString();
|
||||
uh.Log(args.IsTerminating ? LogLevel.Fatal : LogLevel.Error, message);
|
||||
try
|
||||
{
|
||||
uh.Log(args.IsTerminating ? LogLevel.Fatal : LogLevel.Error, message);
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
// Avoid eating the exception if it's during shutdown and the sawmill is already gone.
|
||||
System.Console.WriteLine($"UnhandledException but sawmill is disposed! {message}");
|
||||
}
|
||||
};
|
||||
|
||||
var uo = mgr.GetSawmill("unobserved");
|
||||
TaskScheduler.UnobservedTaskException += (sender, args) =>
|
||||
{
|
||||
uo.Error(args.Exception!.ToString());
|
||||
try
|
||||
{
|
||||
uo.Error(args.Exception!.ToString());
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
// Avoid eating the exception if it's during shutdown and the sawmill is already gone.
|
||||
System.Console.WriteLine($"UnobservedTaskException but sawmill is disposed! {args.Exception}");
|
||||
}
|
||||
#if EXCEPTION_TOLERANCE
|
||||
args.SetObserved(); // don't crash
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user