Prevent break on unhandled ExitGUIException #2119
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Unity 2021.2 beta has an upgraded Mono which now reports unhandled exceptions to the debugger. The previous Mono version (~5.12ish) didn't report unhandled exceptions. This old behaviour does not appear to be deliberate or intentional, and it's not yet clear if this behaviour will be rolled back or not.
However, it has the consequence that the debugger will now frequently stop on unhandled
ExitGUIException
s. These are used as control flow exceptions, thrown in managed code and caught in native code (and therefore considered "unhandled" by Mono and Rider) in order to cancel behaviour in the GUI. The exception is thrown frequently as the user works with the Inspector and other windows, and makes using the Unity editor while debugging very annoying. This PR will ignore any unhandledExitGUIException
s for Unity projects.If the behaviour is rolled back (or even back ported to older Unity versions), the feature is safe - it will only suppress unhandled exceptions with a full name of
UnityEngine.ExitGUIException
. If Unity stop reporting the exception, there will be no exception to match.Note that this Unity change also means that Rider will break on unhandled exceptions that the user throws, which is a change in behaviour from previous versions. Ironically, this release of Rider suppresses unhandled exceptions in IL2CPP, which has always reported them to the debugger, to better match the old editor behaviour (and it also helps avoid situations with empty call stacks due to exceptions being thrown in library code that IL2CPP doesn't generate debug information for, and/or which doesn't have any managed code to decompile and show). This feature is enabled by default but can be disabled in the settings. We can re-evaluate the default setting for the next release, depending on what Unity decides should be their default unhandled exception strategy.