Error handling - log stacktrace from instrumented game
Server response CommandResponse.error
has a property trace
that needs to reach the exception re-raised by Driver, so that the stacktrace from instrumented game exception reaches the logs.
A failed command beacuse of an error on the instrumented game looks like this currently ( c# driver )
2021-09-21 09:39:24.9200|Editor|ERROR|Altom.AltUnityDriver.NullReferenceException : Object reference not set to an instance of an object
at Altom.AltUnityDriver.Commands.DriverCommunicationWebSocket.handleErrors (Altom.AltUnityDriver.Commands.CommandError error) [0x00352] in C:\au\altunityinspector\AltUnityInspector\Assets\Plugins\AltUnityTester\Assets\AltUnityTester\AltUnityDriver\Commands\DriverCommunicationWebSocket.cs:135
at Altom.AltUnityDriver.Commands.DriverCommunicationWebSocket.Recvall[T] (Altom.AltUnityDriver.Commands.CommandParams param) [0x000b8] in C:\au\altunityinspector\AltUnityInspector\Assets\Plugins\AltUnityTester\Assets\AltUnityTester\AltUnityDriver\Commands\DriverCommunicationWebSocket.cs:77
at Altom.AltUnityDriver.Commands.AltUnityCommandReturningAltElement.ReceiveAltUnityObject (Altom.AltUnityDriver.Commands.CommandParams cmdParams) [0x00001] in C:\au\altunityinspector\AltUnityInspector\Assets\Plugins\AltUnityTester\Assets\AltUnityTester\AltUnityDriver\Commands\AltUnityCommandReturningAltElement.cs:14
at Altom.AltUnityDriver.Commands.AltUnitySetText.Execute () [0x00013] in C:\au\altunityinspector\AltUnityInspector\Assets\Plugins\AltUnityTester\Assets\AltUnityTester\AltUnityDriver\Commands\ObjectCommands\AltUnitySetText.cs:15
at Altom.AltUnityDriver.AltUnityObject.SetText (System.String text, System.Boolean submit) [0x00001] in C:\au\altunityinspector\AltUnityInspector\Assets\Plugins\AltUnityTester\Assets\AltUnityTester\AltUnityDriver\AltUnity\AltUnityObject.cs:73
at BaseTest.SetTextInSearchInputField (Altom.AltUnityDriver.AltUnityDriver altDriver, System.String text) [0x00015] in C:\au\altunityinspector\AltUnityInspector\Assets\Tests\Editor\BaseTest.cs:158
at MainPanelTests.TestChangeSelector () [0x000ba] in C:\au\altunityinspector\AltUnityInspector\Assets\Tests\Editor\MainPanelTests.cs:980
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <fb001e01371b4adca20013e0ac763896>:0
UnityEngine.Debug:LogError(Object)
Altom.AltUnityDriver.Logging.UnityTarget:Write(LogEventInfo) (at Assets/Plugins/AltUnityTester/Assets/AltUnityTester/AltUnityDriver/Logging/UnityTarget.cs:23)
NLog.Targets.Target:Write(AsyncLogEventInfo)
NLog.Targets.Target:WriteAsyncThreadSafe(AsyncLogEventInfo)
NLog.Targets.Target:WriteAsyncLogEvent(AsyncLogEventInfo)
NLog.LoggerImpl:WriteToTargetWithFilterChain(Target, FilterResult, LogEventInfo, AsyncContinuation)
NLog.LoggerImpl:Write(Type, TargetWithFilterChain, LogEventInfo, LogFactory)
NLog.Logger:WriteToTargets(LogEventInfo, TargetWithFilterChain)
NLog.Logger:WriteToTargets(LogLevel, IFormatProvider, String)
NLog.Logger:Error(String)
Altom.Editor.AltUnityTestRunListener:TestFinished(ITestResult) (at Assets/Plugins/AltUnityTester/Assets/AltUnityTester/Editor/AltUnityTestRunListener.cs:33)
NUnit.Framework.Internal.Execution.WorkItem:WorkItemComplete()
NUnit.Framework.Internal.Execution.SimpleWorkItem:PerformWork()
NUnit.Framework.Internal.Execution.WorkItem:RunTest()
NUnit.Framework.Internal.Execution.WorkItem:Execute()
NUnit.Framework.Internal.Execution.SimpleWorkItemDispatcher:Dispatch(WorkItem)
NUnit.Framework.Internal.Execution.CompositeWorkItem:RunChildren()
NUnit.Framework.Internal.Execution.CompositeWorkItem:PerformWork()
NUnit.Framework.Internal.Execution.WorkItem:RunTest()
NUnit.Framework.Internal.Execution.WorkItem:Execute()
NUnit.Framework.Internal.Execution.SimpleWorkItemDispatcher:Dispatch(WorkItem)
NUnit.Framework.Internal.Execution.CompositeWorkItem:RunChildren()
NUnit.Framework.Internal.Execution.CompositeWorkItem:PerformWork()
NUnit.Framework.Internal.Execution.WorkItem:RunTest()
NUnit.Framework.Internal.Execution.WorkItem:Execute()
NUnit.Framework.Internal.Execution.SimpleWorkItemDispatcher:RunnerThreadProc()
System.Threading.ThreadHelper:ThreadStart()
What we want is something like this:
2021-09-21 09:39:24.9200|Editor|ERROR|Altom.AltUnityDriver.NullReferenceException : Object reference not set to an instance of an object
at Assets.AltUnityTester.AltUnityServer.Commands.AltUnitySetTextCommand.Execute () [0x000e9] in C:\au\altunityinspector\AltUnityInspector\Assets\Plugins\AltUnityTester\Assets\AltUnityTester\AltUnityServer\Commands\ObjectCommands\AltUnitySetTextCommand.cs:46
at Assets.AltUnityTester.AltUnityServer.Commands.AltUnityCommand`2[TParam,TResult].ExecuteHandleErrors[T] (System.Func`1[TResult] action) [0x00010] in C:\au\altunityinspector\A
ltUnityInspector\Assets\Plugins\AltUnityTester\Assets\AltUnityTester\AltUnityServer\Commands\AltUnityCommand.cs:44
---END OF INSTRUMENTED APP TRACE---
at Altom.AltUnityDriver.Commands.DriverCommunicationWebSocket.handleErrors (Altom.AltUnityDriver.Commands.CommandError error) [0x00352] in C:\au\altunityinspector\AltUnityInspector\Assets\Plugins\AltUnityTester\Assets\AltUnityTester\AltUnityDriver\Commands\DriverCommunicationWebSocket.cs:135
at Altom.AltUnityDriver.Commands.DriverCommunicationWebSocket.Recvall[T] (Altom.AltUnityDriver.Commands.CommandParams param) [0x000b8] in C:\au\altunityinspector\AltUnityInspector\Assets\Plugins\AltUnityTester\Assets\AltUnityTester\AltUnityDriver\Commands\DriverCommunicationWebSocket.cs:77
at Altom.AltUnityDriver.Commands.AltUnityCommandReturningAltElement.ReceiveAltUnityObject (Altom.AltUnityDriver.Commands.CommandParams cmdParams) [0x00001] in C:\au\altunityinspector\AltUnityInspector\Assets\Plugins\AltUnityTester\Assets\AltUnityTester\AltUnityDriver\Commands\AltUnityCommandReturningAltElement.cs:14
at Altom.AltUnityDriver.Commands.AltUnitySetText.Execute () [0x00013] in C:\au\altunityinspector\AltUnityInspector\Assets\Plugins\AltUnityTester\Assets\AltUnityTester\AltUnityDriver\Commands\ObjectCommands\AltUnitySetText.cs:15
at Altom.AltUnityDriver.AltUnityObject.SetText (System.String text, System.Boolean submit) [0x00001] in C:\au\altunityinspector\AltUnityInspector\Assets\Plugins\AltUnityTester\Assets\AltUnityTester\AltUnityDriver\AltUnity\AltUnityObject.cs:73
at BaseTest.SetTextInSearchInputField (Altom.AltUnityDriver.AltUnityDriver altDriver, System.String text) [0x00015] in C:\au\altunityinspector\AltUnityInspector\Assets\Tests\Editor\BaseTest.cs:158
at MainPanelTests.TestChangeSelector () [0x000ba] in C:\au\altunityinspector\AltUnityInspector\Assets\Tests\Editor\MainPanelTests.cs:980
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <fb001e01371b4adca20013e0ac763896>:0
UnityEngine.Debug:LogError(Object)
....