-
-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ref: Use the global LogHandler to capture unhandled Exceptions #731
Conversation
Turns out the Unity Runtime actually "handles" uncaught Exceptions from scripts and hands them of to its global LogHandler. This is presumably the reason why AppDomain.UnhandledException is never being invoked for them. We can capture these Exceptions (and in the future enhance them with native instruction addrs) by shimming the global LogHandler.
_unityLogHandler.LogException(exception, context); | ||
} | ||
|
||
internal void CaptureException(Exception exception, UnityEngine.Object? context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's in context
? Anything useful to add to the event or crumb?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the crazy awesome part: When you're calling Debug.Log("My log message", this);
you can actually pass "whatever" in there as context (the MonoBehaviour in this case). Inside the editor this lets you click the log in the console and highlights the GameObject in the hierarchy. What that means for us is that we could grab all kinds of useful stuff from there.
- The name of the GameObject
- Other components on that GameObject
- Child Count
- e.t.c.
I'm just not sure what to grab. Probably the name.
…unity into ref/loghandler
Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with some questions. Also maybe add links to issues on sentry.io for before and after the change? If there's any change in the context
Looks mostly good, except the changes I suggested. But also, why is the Build - 2020 task failing? |
Turns out the Unity Runtime actually "handles" uncaught Exceptions from scripts and hands them off to its global LogHandler. This is presumably the reason why AppDomain.UnhandledException is never being invoked for them.
We can capture these Exceptions (and in the future enhance them with native instruction addrs) by shimming the global LogHandler.
This completely replaces and removes the Application.OnLogMessageReceived integration and the need to parse exceptions from string.
Resolves #579
Resolves #599