Skip to content

Commit 0f4b45f

Browse files
committed
fix(android): working with latest sdks
1 parent 859e82b commit 0f4b45f

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

src/nssentry.android.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -281,20 +281,26 @@ export namespace NSSentry {
281281
try {
282282
const ex: io.sentry.protocol.SentryException = event.getExceptions().get(0);
283283
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);
293300

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());
298304
}
299305
}
300306
}

0 commit comments

Comments
 (0)