Refactor error/exception/message handling

This adds:
- LuaCsSetup.ExceptionHandler so we can decide how we want to handle
exceptions for unit tests
- LuaCsSetup.MessageHandler so we can redirect logs to the XUnit output
  helper
This commit is contained in:
peelz
2022-08-06 18:10:54 -04:00
parent 3de2d8e550
commit dd1b404c9b
14 changed files with 184 additions and 190 deletions
@@ -93,9 +93,11 @@ namespace Barotrauma
{
LuaCsNetReceives[netMessageName](netMessage, client);
}
catch(Exception e)
catch (Exception e)
{
GameMain.LuaCs.HandleException(e, $"Exception thrown inside NetMessageReceive({netMessageName})", LuaCsSetup.ExceptionType.CSharp);
// TODO: make LuaCsNetworking hold a reference to LuaCsSetup instead of using this global
GameMain.LuaCs.PrintError($"Exception thrown inside NetMessageReceive({netMessageName})", LuaCsMessageOrigin.Unknown);
GameMain.LuaCs.HandleException(e, LuaCsMessageOrigin.Unknown);
}
}
}
@@ -120,7 +122,8 @@ namespace Barotrauma
}
catch (Exception e)
{
GameMain.LuaCs.HandleException(e, $"Exception thrown inside NetMessageReceive({netMessageName})", LuaCsSetup.ExceptionType.CSharp);
GameMain.LuaCs.PrintError($"Exception thrown inside NetMessageReceive({netMessageName})", LuaCsMessageOrigin.Unknown);
GameMain.LuaCs.HandleException(e, LuaCsMessageOrigin.Unknown);
}
}
}