From 3b452770895591778c3132f7055c7a9cc9e155a5 Mon Sep 17 00:00:00 2001 From: Instabug Date: Mon, 28 Jul 2025 13:23:30 +0000 Subject: [PATCH] Handle IllegalStateException in sendNativeFatalCrash to prevent app crash --- .../example/RNInstabugExampleCrashReportingModule.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/default/android/app/src/main/java/com/instabug/react/example/RNInstabugExampleCrashReportingModule.java b/examples/default/android/app/src/main/java/com/instabug/react/example/RNInstabugExampleCrashReportingModule.java index 4ccb7ad3c..a91baa424 100644 --- a/examples/default/android/app/src/main/java/com/instabug/react/example/RNInstabugExampleCrashReportingModule.java +++ b/examples/default/android/app/src/main/java/com/instabug/react/example/RNInstabugExampleCrashReportingModule.java @@ -37,9 +37,13 @@ public void sendNativeNonFatal(final String exceptionObject) { @ReactMethod public void sendNativeFatalCrash() { - throw new IllegalStateException("Unhandled IllegalStateException from Instabug Test App"); + try { + throw new IllegalStateException("Unhandled IllegalStateException from Instabug Test App"); + } catch (IllegalStateException e) { + // Report the fatal crash to Instabug or log it, instead of crashing the app + CrashReporting.report(e); + } } - @ReactMethod public void sendANR() { sendHang(20000);