-
-
Notifications
You must be signed in to change notification settings - Fork 62
fix: Capture Debug.LogError as message, not exception
#2377
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
14a34b4
Capture message instead of synthetic error exception
bitsandfoxes 303d03b
Pull the .NET changes
bitsandfoxes ad85a57
Stack trace creation tweak
bitsandfoxes 90b2d2d
Merged feat/bump-version6
bitsandfoxes db1f804
Completely replace synthetic log exception with message
bitsandfoxes 1afda74
Naming
bitsandfoxes 4b4e7b4
Merged feat/bump-version6 again
bitsandfoxes fc4c0d5
Merge branch 'feat/bump-version6' into fix/debug-logerror
bitsandfoxes 6df9de2
Updated CHANGELOG.md
bitsandfoxes 90224cb
Updated Debug.LogError test
bitsandfoxes b608e71
Restored defaults
bitsandfoxes b333504
Testing
bitsandfoxes 2b5a6bf
Pass in handled in prep to checking
bitsandfoxes 27baffb
Synthetic
bitsandfoxes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
173 changes: 0 additions & 173 deletions
173
src/Sentry.Unity/Integrations/UnityErrorLogException.cs
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Threading; | ||
| using Sentry.Protocol; | ||
|
|
||
| namespace Sentry.Unity.Integrations; | ||
|
|
||
| /// <summary> | ||
| /// Factory for creating SentryEvent objects from Unity log messages and stacktraces | ||
| /// </summary> | ||
| internal static class UnityLogEventFactory | ||
| { | ||
| /// <summary> | ||
| /// Creates a message event with stacktrace attached via threads (for Debug.LogError) | ||
| /// </summary> | ||
| /// <param name="message">The log message</param> | ||
| /// <param name="stackTrace">The Unity stacktrace string</param> | ||
| /// <param name="level">The Sentry event level</param> | ||
| /// <param name="options">Sentry Unity options</param> | ||
| /// <returns>A SentryEvent with the message and stacktrace as threads</returns> | ||
| public static SentryEvent CreateMessageEvent( | ||
| string message, | ||
| string stackTrace, | ||
| SentryLevel level, | ||
| SentryUnityOptions options) | ||
| { | ||
| var frames = UnityStackTraceParser.Parse(stackTrace, options); | ||
| frames.Reverse(); | ||
|
|
||
| var thread = CreateThreadFromStackTrace(frames); | ||
|
|
||
| return new SentryEvent | ||
| { | ||
| Message = message, | ||
| Level = level, | ||
| SentryThreads = [thread] | ||
| }; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Creates an exception event from Unity log data (for exceptions on WebGL) | ||
| /// </summary> | ||
| /// <param name="message">The log message</param> | ||
| /// <param name="stackTrace">The Unity stacktrace string</param> | ||
| /// <param name="handled">Whether the exception was handled or not</param> | ||
| /// /// <param name="options">Sentry Unity options</param> | ||
| /// <returns>A SentryEvent with a synthetic exception</returns> | ||
| public static SentryEvent CreateExceptionEvent( | ||
| string message, | ||
| string stackTrace, | ||
| bool handled, | ||
| SentryUnityOptions options) | ||
| { | ||
| var frames = UnityStackTraceParser.Parse(stackTrace, options); | ||
| frames.Reverse(); | ||
|
|
||
| return new SentryEvent | ||
| { | ||
| SentryExceptions = [new SentryException | ||
| { | ||
| Stacktrace = new SentryStackTrace { Frames = frames }, | ||
| Value = message, | ||
| Type = "LogException", | ||
| Mechanism = new Mechanism | ||
| { | ||
| Handled = handled, | ||
| Type = "unity.log", | ||
| Terminal = false, | ||
| Synthetic = true | ||
| } | ||
| }], | ||
| Level = SentryLevel.Error | ||
| }; | ||
| } | ||
|
|
||
| private static SentryThread CreateThreadFromStackTrace(List<SentryStackFrame> frames) | ||
| { | ||
| var currentThread = Thread.CurrentThread; | ||
| return new SentryThread | ||
| { | ||
| Crashed = false, | ||
| Current = true, | ||
| Name = currentThread.Name, | ||
| Id = currentThread.ManagedThreadId, | ||
| Stacktrace = new SentryStackTrace { Frames = frames } | ||
| }; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.