nokola
Topic Author
Posts: 119
Joined: 10 Mar 2015, 05:29

Improved error handling (code)

12 Nov 2017, 09:33

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:
        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;
            }
        }
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. :)
 
User avatar
jsantos
Site Admin
Posts: 1872
Joined: 20 Jan 2012, 17:18
Contact:

Re: Improved error handling (code)

13 Nov 2017, 11:42

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!
 
nokola
Topic Author
Posts: 119
Joined: 10 Mar 2015, 05:29

Re: Improved error handling (code)

13 Nov 2017, 18:35

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
 
User avatar
jsantos
Site Admin
Posts: 1872
Joined: 20 Jan 2012, 17:18
Contact:

Re: Improved error handling (code)

16 Nov 2017, 11:26

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.
 
nokola
Topic Author
Posts: 119
Joined: 10 Mar 2015, 05:29

Re: Improved error handling (code)

17 Nov 2017, 03:03

thanks!

Who is online

Users browsing this forum: No registered users and 1 guest