File tree Expand file tree Collapse file tree 5 files changed +20
-7
lines changed Expand file tree Collapse file tree 5 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -215,14 +215,22 @@ - (SentryEvent *)buildExceptionEvent:(NSException *)exception
215215
216216 event.exceptions = @[ sentryException ];
217217
218+ SentryMechanism *mechanism = [[SentryMechanism alloc ] initWithType: @" NSException" ];
219+ mechanism.desc = exception.reason ;
220+ mechanism.data = sentry_sanitize (exception.userInfo );
221+
218222#if TARGET_OS_OSX
219223 // When a exception class is SentryUseNSExceptionCallstackWrapper, we should use the thread from
220224 // it
221225 if ([exception isKindOfClass: [SentryUseNSExceptionCallstackWrapper class ]]) {
222226 event.threads = [(SentryUseNSExceptionCallstackWrapper *)exception buildThreads ];
227+ event.level = kSentryLevelFatal ;
228+
229+ // Only exceptions through `_crashOnExceptions` are guaranteed to be unhandled
230+ mechanism.handled = @(NO );
223231 }
224232#endif
225-
233+ sentryException. mechanism = mechanism;
226234 [self setUserInfo: exception.userInfo withEvent: event];
227235 return event;
228236}
Original file line number Diff line number Diff line change 88# import " SentryDependencyContainer.h"
99# import " SentrySDK+Private.h"
1010# import " SentrySDK.h"
11+ # import " SentryScope.h"
12+ # import " SentrySwift.h"
1113
1214@implementation SentryCrashExceptionApplicationHelper
1315
@@ -21,9 +23,11 @@ + (void)reportException:(NSException *)exception
2123
2224+ (void )_crashOnException : (NSException *)exception
2325{
24- [SentrySDK captureCrashOnException: exception];
26+ SentryScope *scope = [[SentryScope alloc ] initWithScope: SentrySDK.currentHub.scope];
27+ [scope setLevel: kSentryLevelFatal ];
28+ [SentrySDK captureCrashOnException: exception withScope: scope];
2529# if !(SENTRY_TEST || SENTRY_TEST_CI)
26- abort ();
30+ // abort();
2731# endif
2832}
2933
Original file line number Diff line number Diff line change @@ -398,15 +398,15 @@ + (SentryId *)captureException:(NSException *)exception withScope:(SentryScope *
398398
399399#if TARGET_OS_OSX
400400
401- + (SentryId *)captureCrashOnException : (NSException *)exception
401+ + (SentryId *)captureCrashOnException : (NSException *)exception withScope : (SentryScope *) scope
402402{
403403 SentryUseNSExceptionCallstackWrapper *wrappedException =
404404 [[SentryUseNSExceptionCallstackWrapper alloc ]
405405 initWithName: exception.name
406406 reason: exception.reason
407407 userInfo: exception.userInfo
408408 callStackReturnAddresses: exception.callStackReturnAddresses];
409- return [SentrySDK captureException: wrappedException withScope: SentrySDK.currentHub. scope];
409+ return [SentrySDK captureException: wrappedException withScope: scope];
410410}
411411
412412#endif // TARGET_OS_OSX
Original file line number Diff line number Diff line change @@ -67,7 +67,8 @@ NS_ASSUME_NONNULL_BEGIN
6767 *
6868 */
6969+ (SentryId *)captureCrashOnException : (NSException *)exception
70- NS_SWIFT_NAME(captureCrashOn(exception:));
70+ withScope : (SentryScope *)scope
71+ NS_SWIFT_NAME(captureCrashOn(exception:withScope:));
7172
7273#endif // TARGET_OS_OSX
7374
Original file line number Diff line number Diff line change @@ -1006,7 +1006,7 @@ class SentrySDKTests: XCTestCase {
10061006 func testCaptureCrashOnException( ) {
10071007 givenSdkWithHub ( )
10081008
1009- SentrySDK . captureCrashOn ( exception: fixture. exception)
1009+ SentrySDK . captureCrashOn ( exception: fixture. exception, withScope : fixture . scope )
10101010
10111011 let client = fixture. client
10121012 XCTAssertEqual ( 1 , client. captureExceptionWithScopeInvocations. count)
You can’t perform that action at this time.
0 commit comments