diff --git a/CHANGELOG.md b/CHANGELOG.md index 98edc5f78..ee1b20bd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ Bugsnag Notifiers on other platforms. ## Enhancements +* Add `originalError` property to `BugsnagEvent` + [#541](https://github.com/bugsnag/bugsnag-cocoa/pull/541) + * Create structured `BugsnagThread` class [#532](https://github.com/bugsnag/bugsnag-cocoa/pull/532) diff --git a/Source/BugsnagClient.m b/Source/BugsnagClient.m index 989c8cc8d..8c3f4301e 100644 --- a/Source/BugsnagClient.m +++ b/Source/BugsnagClient.m @@ -766,6 +766,7 @@ - (void)notifyError:(NSError *)error [self notify:wrapper handledState:state block:^(BugsnagEvent *_Nonnull event) { + event.originalError = error; [event addMetadata:@{ @"code" : @(error.code), @"domain" : error.domain, @@ -872,6 +873,7 @@ - (void)notify:(NSException *)exception metadata:self.metadata handledState:handledState session:self.sessionTracker.runningSession]; + event.originalError = exception; if (block) { block(event); diff --git a/Source/BugsnagEvent.h b/Source/BugsnagEvent.h index de60e7276..a59348784 100644 --- a/Source/BugsnagEvent.h +++ b/Source/BugsnagEvent.h @@ -138,5 +138,15 @@ initWithErrorName:(NSString *_Nonnull)name */ @property(readonly, nonnull) NSMutableArray *threads; +/** + * The original object that caused the error in your application. This value will only be populated for + * non-fatal errors which did not terminate the process, and will contain an NSError or NSException. + * + * Manipulating this field does not affect the error information reported to the + * Bugsnag dashboard. Use event.errors to access and amend the representation of + * the error that will be sent. + */ +@property(nullable) id originalError; + @end diff --git a/UPGRADING.md b/UPGRADING.md index 07d15ff70..e53238457 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -221,6 +221,7 @@ This is now BugsnagEvent. ```diff + event.unhandled ++ event.originalError ``` `event.device` is now a structured class with properties for each value, rather than an `NSDictionary`.