ScriptGlue: Added Log.Exception

- Also pushed missing List Editor fix
This commit is contained in:
Simon Lübeß
2024-01-15 01:21:56 +01:00
parent 49db3a28c8
commit ceb4241216
6 changed files with 96 additions and 29 deletions
+11 -5
View File
@@ -806,21 +806,22 @@ static class ScriptEngine
return scriptClass;
}
internal static void HandleMonoException(MonoException* exception, ScriptInstance sourceInstance = null)
internal static void HandleMonoException(MonoException* exception, UUID entityId)
{
MonoExceptionHelper wrappedException = new MonoExceptionHelper(exception);
String entityInfo = scope .();
if (sourceInstance != null)
if (entityId != .Zero)
{
wrappedException.Instance = sourceInstance.EntityId;
wrappedException.Instance = entityId;
Result<Entity> sourceEntity = Context.GetEntityByID(sourceInstance.EntityId);
Result<Entity> sourceEntity = Context.GetEntityByID(entityId);
if (sourceEntity case .Ok(let e))
{
entityInfo.AppendF($" ({e.Name} | {sourceInstance.EntityId})");
entityInfo.AppendF($" ({e.Name} | {entityId})");
}
}
@@ -829,6 +830,11 @@ static class ScriptEngine
wrappedException.ReleaseRef();
}
internal static void HandleMonoException(MonoException* exception, ScriptInstance sourceInstance = null)
{
HandleMonoException(exception, sourceInstance?.EntityId ?? .Zero);
}
public static void ShowScriptEditor(Entity entity, ScriptComponent* scriptComponent)
{
if (scriptComponent.Instance == null)
+12 -2
View File
@@ -107,8 +107,10 @@ static class ScriptGlue
}
}
[RegisterCall("Log::LogMessage_Impl")]
static void Log(int32 logLevel, MonoString* message)
#region Log
[RegisterCall("ScriptGlue::Log_LogMessage")]
static void Log_LogMessage(int32 logLevel, MonoString* message)
{
char8* utfMessage = Mono.mono_string_to_utf8(message);
@@ -117,6 +119,14 @@ static class ScriptGlue
Mono.mono_free(utfMessage);
}
[RegisterCall("ScriptGlue::Log_LogException")]
static void Log_LogException(MonoException* exception, UUID entityId)
{
ScriptEngine.HandleMonoException(exception, entityId);
}
#endregion
#region Input
[RegisterCall("Input::IsKeyPressed")]