@@ -281,20 +281,26 @@ export namespace NSSentry {
281
281
try {
282
282
const ex : io . sentry . protocol . SentryException = event . getExceptions ( ) . get ( 0 ) ;
283
283
if ( ex && ex . getType ( ) === 'NativeScriptException' ) {
284
- const privateMethod = io . sentry . SentryEvent . class . getDeclaredMethod ( 'getThrowable' , null ) ;
285
- privateMethod . setAccessible ( true ) ;
286
- const returnValue : java . lang . Throwable = privateMethod . invoke ( event , null ) ;
287
- if ( returnValue instanceof io . sentry . exception . ExceptionMechanismException ) {
288
- const throwable : java . lang . Throwable = returnValue . getThrowable ( ) ;
289
- if ( throwable instanceof ( com as any ) . tns . NativeScriptException ) {
290
- const jsStackTrace : string = ( throwable as any ) . getIncomingStackTrace ( ) ;
291
- if ( jsStackTrace ) {
292
- const stack = parseErrorStack ( { stack : jsStackTrace } as any ) ;
284
+ let mechanism = event . getThrowable && event . getThrowable ( ) ;
285
+ if ( ! mechanism ) {
286
+ const privateMethod = io . sentry . SentryEvent . class . getDeclaredMethod ( 'getThrowable' , null ) ;
287
+ privateMethod . setAccessible ( true ) ;
288
+ mechanism = privateMethod . invoke ( event , null ) ;
289
+ }
290
+ let throwable ;
291
+ if ( mechanism instanceof io . sentry . exception . ExceptionMechanismException ) {
292
+ throwable = mechanism . getThrowable ( ) ;
293
+ } else if ( mechanism instanceof ( com as any ) . tns . NativeScriptException ) {
294
+ throwable = mechanism ;
295
+ }
296
+ if ( throwable ) {
297
+ const jsStackTrace : string = ( throwable as any ) . getIncomingStackTrace ( ) ;
298
+ if ( jsStackTrace ) {
299
+ const stack = parseErrorStack ( { stack : jsStackTrace } as any ) ;
293
300
294
- const convertedFrames = convertNativescriptFramesToSentryFrames ( stack as any ) ;
295
- convertedFrames . forEach ( ( frame ) => rewriteFrameIntegration . _iteratee ( frame ) ) ;
296
- addExceptionInterface ( event , 'Error' , throwable . getMessage ( ) , convertedFrames . reverse ( ) ) ;
297
- }
301
+ const convertedFrames = convertNativescriptFramesToSentryFrames ( stack as any ) ;
302
+ convertedFrames . forEach ( ( frame ) => rewriteFrameIntegration . _iteratee ( frame ) ) ;
303
+ addExceptionInterface ( event , 'Error' , throwable . getMessage ( ) , convertedFrames . reverse ( ) ) ;
298
304
}
299
305
}
300
306
}
0 commit comments