Improved error handling (code)
I noticed that the default exception handling in Noesis Unity in NoesisError.cs do not give back stack trace into my code in the Check() function.
If I change SetPendingError(...) to this, I get much better stack traces:
Example:
Before: stack trace AFTER the error actually happened
[Exception] NoesisException: Target not found
View.Noesis_View_TouchDown_() Assets/NoesisGUI/Plugins/API/Core/NoesisView.cs:370
View.TouchDown() Assets/NoesisGUI/Plugins/API/Core/NoesisView.cs:218
NoesisView.TouchDown() Assets/NoesisGUI/Plugins/NoesisView.cs:258
NoesisExtensions.PointerDown() Assets/XAMLs/FantasiaPhone/NoesisExtensions.cs:179
ImagePointerEvents.ProcessPendingInputEventsIfAny() Assets/Scripts/ImagePointerEvents.cs:238
ImagePointerEvents.Update() Assets/Scripts/ImagePointerEvents.cs:127
After updat: stack trace AS the error happens:
[Exception] NoesisException: Target not found
Storyboard.Stop() Assets/NoesisGUI/Plugins/API/Proxies/Storyboard.cs:138
StoryboardExtensions.StopStoryboard() Assets/XAMLs/FantasiaPhone/UnityShared/StoryboardExtensions.cs:53
TiltEffect.StopTiltReturnStoryboardAndCleanup() Assets/XAMLs/FantasiaPhone/UnityShared/TiltEffect.cs:567
TiltEffect.BeginTiltEffect() Assets/XAMLs/FantasiaPhone/UnityShared/TiltEffect.cs:354
TiltEffect.TryStartTiltEffect() Assets/XAMLs/FantasiaPhone/UnityShared/TiltEffect.cs:284
TiltEffect.TiltEffect_ManipulationStarted() Assets/XAMLs/FantasiaPhone/UnityShared/TiltEffect.cs:194
UIElement.RaiseManipulationStarted() Assets/NoesisGUI/Plugins/API/Proxies/UIElement.cs:1729
Debug.LogException()
Error.SetNativePendingError() Assets/NoesisGUI/Plugins/API/Core/NoesisError.cs:40
UIElement.RaiseManipulationStarted() Assets/NoesisGUI/Plugins/API/Proxies/UIElement.cs:1734
View.Noesis_View_TouchDown()
View.Noesis_View_TouchDown_() Assets/NoesisGUI/Plugins/API/Core/NoesisView.cs:370
View.TouchDown() Assets/NoesisGUI/Plugins/API/Core/NoesisView.cs:218
NoesisView.TouchDown() Assets/NoesisGUI/Plugins/NoesisView.cs:258
NoesisExtensions.PointerDown() Assets/XAMLs/FantasiaPhone/NoesisExtensions.cs:179
ImagePointerEvents.ProcessPendingInputEventsIfAny() Assets/Scripts/ImagePointerEvents.cs:238
ImagePointerEvents.Update() Assets/Scripts/ImagePointerEvents.cs:127
Notice the extra TiltEffect.* stack traces that are very valuable - point to the actual code triggering the error.
Is it possible to improve/change the error handling in future update of Noesis to support the current error's stack trace like above? or is there a reason not to?
Regardless, I'll be using the new code with the "throw ..." that happens just in time, much more useful.
If I change SetPendingError(...) to this, I get much better stack traces:
Code: Select all
private static void SetPendingError(string desc)
{
throw new NoesisException(desc); <---------- new code
// old and obsolete code below:
// Do not overwrite if there is already an exception pending
if (_pendingError.Length == 0)
{
_pendingError = desc;
}
}
Before: stack trace AFTER the error actually happened
[Exception] NoesisException: Target not found
View.Noesis_View_TouchDown_() Assets/NoesisGUI/Plugins/API/Core/NoesisView.cs:370
View.TouchDown() Assets/NoesisGUI/Plugins/API/Core/NoesisView.cs:218
NoesisView.TouchDown() Assets/NoesisGUI/Plugins/NoesisView.cs:258
NoesisExtensions.PointerDown() Assets/XAMLs/FantasiaPhone/NoesisExtensions.cs:179
ImagePointerEvents.ProcessPendingInputEventsIfAny() Assets/Scripts/ImagePointerEvents.cs:238
ImagePointerEvents.Update() Assets/Scripts/ImagePointerEvents.cs:127
After updat: stack trace AS the error happens:
[Exception] NoesisException: Target not found
Storyboard.Stop() Assets/NoesisGUI/Plugins/API/Proxies/Storyboard.cs:138
StoryboardExtensions.StopStoryboard() Assets/XAMLs/FantasiaPhone/UnityShared/StoryboardExtensions.cs:53
TiltEffect.StopTiltReturnStoryboardAndCleanup() Assets/XAMLs/FantasiaPhone/UnityShared/TiltEffect.cs:567
TiltEffect.BeginTiltEffect() Assets/XAMLs/FantasiaPhone/UnityShared/TiltEffect.cs:354
TiltEffect.TryStartTiltEffect() Assets/XAMLs/FantasiaPhone/UnityShared/TiltEffect.cs:284
TiltEffect.TiltEffect_ManipulationStarted() Assets/XAMLs/FantasiaPhone/UnityShared/TiltEffect.cs:194
UIElement.RaiseManipulationStarted() Assets/NoesisGUI/Plugins/API/Proxies/UIElement.cs:1729
Debug.LogException()
Error.SetNativePendingError() Assets/NoesisGUI/Plugins/API/Core/NoesisError.cs:40
UIElement.RaiseManipulationStarted() Assets/NoesisGUI/Plugins/API/Proxies/UIElement.cs:1734
View.Noesis_View_TouchDown()
View.Noesis_View_TouchDown_() Assets/NoesisGUI/Plugins/API/Core/NoesisView.cs:370
View.TouchDown() Assets/NoesisGUI/Plugins/API/Core/NoesisView.cs:218
NoesisView.TouchDown() Assets/NoesisGUI/Plugins/NoesisView.cs:258
NoesisExtensions.PointerDown() Assets/XAMLs/FantasiaPhone/NoesisExtensions.cs:179
ImagePointerEvents.ProcessPendingInputEventsIfAny() Assets/Scripts/ImagePointerEvents.cs:238
ImagePointerEvents.Update() Assets/Scripts/ImagePointerEvents.cs:127
Notice the extra TiltEffect.* stack traces that are very valuable - point to the actual code triggering the error.
Is it possible to improve/change the error handling in future update of Noesis to support the current error's stack trace like above? or is there a reason not to?
Regardless, I'll be using the new code with the "throw ..." that happens just in time, much more useful.
Re: Improved error handling (code)
The reason the error handling mechanism is doing that is because we cannot throw from C# world when being invoked from C++ and vice versa. The reason it is working for you is because you are in Microsoft world where the C++ and C# are using the same internal compiler infrastructure. But it won't work in platforms where mono is being used like macOS, iOS...
But, thanks to your comments I think we can improve the mechanism to have something similar to your patch. Could you please create a ticket to handle this? Thanks!
But, thanks to your comments I think we can improve the mechanism to have something similar to your patch. Could you please create a ticket to handle this? Thanks!
Re: Improved error handling (code)
Thanks for the info - good to know! Is it safe to leave the above code ON for Unity in my project for the moment? Or could it cause unexpected behaviour?
Opened http://www.noesisengine.com/bugs/view.php?id=1191
Opened http://www.noesisengine.com/bugs/view.php?id=1191
Re: Improved error handling (code)
It could cause unexpected behavior in mono platforms but don't worry much about it because we are going to fix it in the next version.
Who is online
Users browsing this forum: maherne and 3 guests