From bc4476e103c0d97f1c8a3eb9113fd8118ef6b263 Mon Sep 17 00:00:00 2001 From: Instabug Date: Mon, 11 Aug 2025 13:58:57 +0000 Subject: [PATCH] Handle IllegalStateException in sendNativeFatalCrash to prevent unintentional app crashes during testing. --- .../RNInstabugExampleCrashReportingModule.java | 13 +++++++++++-- 1 file changed, 11 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..d8fb6ace8 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,18 @@ 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) { + @ReactMethod + public void sendNativeFatalCrash() { + try { + throw new IllegalStateException("Unhandled IllegalStateException from Instabug Test App"); + } catch (IllegalStateException e) { + // Report the exception instead of crashing the app directly + CrashReporting.report(e); + } } - @ReactMethod public void sendANR() { sendHang(20000);