Skip to content
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

PLAT-9602 make unhandled non null #813

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

- Changed `Configuration.DiscardClasses` and `Configuration.RedactedKeys` to Regex types. [#807](https://github.com/bugsnag/bugsnag-unity/pull/807)

- `Event.Unhandled` is (accessed via OnError and OnSend callbacks) is now non null. [#813](https://github.com/bugsnag/bugsnag-unity/pull/813)

### Bug Fixes

- Added a null check to the Bugsnag client to prevent crashes when accessing the client before it has been initialised [#788](https://github.com/bugsnag/bugsnag-unity/pull/788)
Expand Down
2 changes: 2 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Upgrading

If you are using the `DiscardClasses` and `RedactedKeys` sections of the Bugsnag Unity Configuration Window, you can enter Regex patterns as strings and they will be converted into Regex objects when the Bugsnag SDK is started.

`Event.Unhandled` (accessed via OnError and OnSend callbacks) is now non null.

## 6.x to 7.x

When building using Unity 2019+, the Bugsnag SDK now uses a new method to intercept uncaught C# exceptions. This allows us access to the original exception object, meaning more accurate exception data and full support for inner exceptions.
Expand Down
2 changes: 1 addition & 1 deletion src/BugsnagUnity/Native/Android/NativeEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public NativeEvent(AndroidJavaObject androidJavaObject) : base (androidJavaObjec

public List<IThread> Threads => GetThreads();

public bool? Unhandled { get => NativePointer.Call<bool>("isUnhandled"); set => NativePointer.Call("setUnhandled", (bool)value); }
public bool Unhandled { get => NativePointer.Call<bool>("isUnhandled"); set => NativePointer.Call("setUnhandled", (bool)value); }

private Severity GetSeverity()
{
Expand Down
8 changes: 7 additions & 1 deletion src/BugsnagUnity/Native/Cocoa/NativeEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ public class NativeEvent : NativePayloadClassWrapper, IEvent

public string GroupingHash { get => GetNativeString(GROUPING_HASH_KEY); set => SetNativeString(GROUPING_HASH_KEY, value); }

public bool? Unhandled { get => GetNativeBool(UNHANDLED_KEY); set => SetNativeBool(UNHANDLED_KEY, value); }
public bool Unhandled {
get {
var nativeBool = GetNativeBool(UNHANDLED_KEY);
return nativeBool.HasValue ? nativeBool.Value : false;
}
set => SetNativeBool(UNHANDLED_KEY, value);
}

private List<IBreadcrumb> _breadcrumbs = new List<IBreadcrumb>();

Expand Down
17 changes: 16 additions & 1 deletion src/BugsnagUnity/Payload/Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ internal Event(Dictionary<string, object> serialisedPayload)
{
Add("unhandled", eventObject["unhandled"]);
}
else
{
Add("unhandled", false);
}

if (eventObject["severity"] != null)
{
Add("severity", eventObject["severity"]);
Expand Down Expand Up @@ -190,7 +195,17 @@ internal void AddAndroidProjectPackagesToEvent(string[] packages)

internal LogType? LogType { get; }

public bool? Unhandled { get => (bool)Get("unhandled"); set => Add("unhandled",value); }
public bool Unhandled {
get {
var currentValue = Get("unhandled");
if (currentValue == null)
{
return false;
}
return (bool)currentValue;
}
set => Add("unhandled",value);
}

internal bool IsHandled
{
Expand Down
2 changes: 1 addition & 1 deletion src/BugsnagUnity/Payload/IEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public interface IEvent: IMetadataEditor, IUserEditor, IFeatureFlagStore

List<IThread> Threads { get; }

bool? Unhandled { get; set; }
bool Unhandled { get; set; }
}
}