Skip to content

Commit 696f59d

Browse files
authored
PLAT-9602 make unhandled non null (#813)
* Make unhandled non null * changelog and upgrading guide * typo
1 parent da97945 commit 696f59d

File tree

6 files changed

+29
-4
lines changed

6 files changed

+29
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

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

11+
- `Event.Unhandled` is (accessed via OnError and OnSend callbacks) is now non-nullable. [#813](https://github.com/bugsnag/bugsnag-unity/pull/813)
12+
1113
### Bug Fixes
1214

1315
- 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)

UPGRADING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Upgrading
77

88
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.
99

10+
`Event.Unhandled` (accessed via OnError and OnSend callbacks) is now non-nullable.
11+
1012
## 6.x to 7.x
1113

1214
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.

src/BugsnagUnity/Native/Android/NativeEvent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public NativeEvent(AndroidJavaObject androidJavaObject) : base (androidJavaObjec
2828

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

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

3333
private Severity GetSeverity()
3434
{

src/BugsnagUnity/Native/Cocoa/NativeEvent.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ public class NativeEvent : NativePayloadClassWrapper, IEvent
2828

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

31-
public bool? Unhandled { get => GetNativeBool(UNHANDLED_KEY); set => SetNativeBool(UNHANDLED_KEY, value); }
31+
public bool Unhandled {
32+
get {
33+
var nativeBool = GetNativeBool(UNHANDLED_KEY);
34+
return nativeBool.HasValue ? nativeBool.Value : false;
35+
}
36+
set => SetNativeBool(UNHANDLED_KEY, value);
37+
}
3238

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

src/BugsnagUnity/Payload/Event.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ internal Event(Dictionary<string, object> serialisedPayload)
6161
{
6262
Add("unhandled", eventObject["unhandled"]);
6363
}
64+
else
65+
{
66+
Add("unhandled", false);
67+
}
68+
6469
if (eventObject["severity"] != null)
6570
{
6671
Add("severity", eventObject["severity"]);
@@ -190,7 +195,17 @@ internal void AddAndroidProjectPackagesToEvent(string[] packages)
190195

191196
internal LogType? LogType { get; }
192197

193-
public bool? Unhandled { get => (bool)Get("unhandled"); set => Add("unhandled",value); }
198+
public bool Unhandled {
199+
get {
200+
var currentValue = Get("unhandled");
201+
if (currentValue == null)
202+
{
203+
return false;
204+
}
205+
return (bool)currentValue;
206+
}
207+
set => Add("unhandled",value);
208+
}
194209

195210
internal bool IsHandled
196211
{

src/BugsnagUnity/Payload/IEvent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ public interface IEvent: IMetadataEditor, IUserEditor, IFeatureFlagStore
2727

2828
List<IThread> Threads { get; }
2929

30-
bool? Unhandled { get; set; }
30+
bool Unhandled { get; set; }
3131
}
3232
}

0 commit comments

Comments
 (0)