Log Exceptions in thrown by Script OnUpdate-Function

This commit is contained in:
Simon Lübeß
2023-07-20 17:48:50 +02:00
parent 3e55a1614a
commit 78ba016b03
2 changed files with 17 additions and 2 deletions
+10 -1
View File
@@ -199,9 +199,18 @@ class ScriptClass : SharpClass
public void OnUpdate(MonoObject* instance, float deltaTime)
{
MonoException* exception;
MonoException* exception = null;
if (_onUpdate != null)
_onUpdate(instance, deltaTime, &exception);
if (exception != null)
{
char8* str = Mono.mono_string_to_utf8(exception.Message);
Log.EngineLogger.Error($"Exception in \"{_fullName}.OnUpdate\". Message:\"{StringView(str)}\"");
Mono.mono_free(str);
}
}
public void OnDestroy(MonoObject* instance)