### Start Example App Packager Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/CONTRIBUTING.md Starts the Metro server for the example application, which is used to test library changes. ```sh yarn example start ``` -------------------------------- ### Complete Setup Example Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/usage/basic-usage.md This example demonstrates how to register both JavaScript and native exception handlers simultaneously using `setJSExceptionHandler` and `setNativeExceptionHandler`. ```typescript import { setJSExceptionHandler, setNativeExceptionHandler, } from 'react-native-global-exception-handler'; setJSExceptionHandler((error, isFatal) => { console.log('JS Error:', error, isFatal); }, true); setNativeExceptionHandler((errorString) => { console.log('Native Error:', errorString); }, { forceAppToQuit: true, callPreviouslyDefinedHandler: false, }); ``` -------------------------------- ### Install Dependencies Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/examples/react-native-sentry-integration.md Install the necessary packages for Sentry integration and run pod install for iOS. ```bash npm install react-native-global-exception-handler @sentry/react-native cd ios && pod install ``` -------------------------------- ### Run Example App on iOS Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/CONTRIBUTING.md Builds and runs the example application on an iOS simulator or device. ```sh yarn example ios ``` -------------------------------- ### Install Dependencies Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/examples/react-native-crashlytics-integration.md Install the necessary packages for Crashlytics integration and run `pod install` for iOS. ```bash npm install react-native-global-exception-handler @react-native-firebase/app @react-native-firebase/crashlytics cd ios && pod install ``` -------------------------------- ### Run Example App on Android Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/CONTRIBUTING.md Builds and runs the example application on an Android device or emulator. ```sh yarn example android ``` -------------------------------- ### Start Local Development Server Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/README.md Starts a local development server for live previewing changes. Changes are reflected live without server restarts. ```bash yarn start ``` -------------------------------- ### Install Dependencies with Yarn Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/README.md Run this command to install project dependencies using Yarn. ```bash yarn ``` -------------------------------- ### Install and Uninstall Dependencies Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/migration/migrating-from-react-native-exception-handler.md Replace the old exception handler package with the new one using npm or yarn, followed by a pod install for iOS. ```bash npm uninstall react-native-exception-handler npm install react-native-global-exception-handler cd ios && pod install ``` -------------------------------- ### Complete Sentry Integration Example Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/examples/react-native-sentry-integration.md A comprehensive example combining Sentry initialization with both JavaScript and native exception handlers. ```typescript import { Platform } from 'react-native'; import * as Sentry from '@sentry/react-native'; import { setJSExceptionHandler, setNativeExceptionHandler, } from 'react-native-global-exception-handler'; Sentry.init({ dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0', }); setJSExceptionHandler((error, isFatal) => { Sentry.captureException(error, { level: isFatal ? 'fatal' : 'error', tags: { layer: 'javascript' }, }); }, true); setNativeExceptionHandler((errorString) => { Sentry.captureMessage(errorString, { level: 'fatal', tags: { layer: 'native', platform: Platform.OS }, }); }, { forceAppToQuit: Platform.OS === 'android', callPreviouslyDefinedHandler: false, }); ``` -------------------------------- ### Custom Error Screen Setup (Android) Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/examples/basic-examples.md Provides an example of how to replace the default error screen activity with a custom one on Android by calling `replaceErrorScreenActivityClass` in `MainApplication.kt`. ```kotlin // In MainApplication.kt GlobalExceptionHandlerModule.replaceErrorScreenActivityClass(CustomErrorActivity::class.java) ``` -------------------------------- ### Install iOS dependencies with CocoaPods Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/overview/installation.md After installing the package, navigate to the 'ios' directory and run 'pod install' to link the native iOS dependencies. ```bash cd ios && pod install ``` -------------------------------- ### Install CocoaPods Dependencies Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/example/README.md Before running the iOS app, install CocoaPods dependencies. Run 'bundle install' once to install the bundler, and 'bundle exec pod install' after updating native dependencies. ```sh bundle install bundle exec pod install ``` -------------------------------- ### Install react-native-global-exception-handler Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/overview/getting-started.md Install the package using npm or yarn and run pod install for iOS dependencies. ```bash npm install react-native-global-exception-handler cd ios && pod install ``` -------------------------------- ### Install react-native-global-exception-handler Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/README.md Install the package using npm or yarn. Requires React Native 0.68+. ```sh npm install react-native-global-exception-handler # or yarn add react-native-global-exception-handler ``` -------------------------------- ### Start Metro Bundler Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/example/README.md Run this command from the root of your React Native project to start the Metro dev server. This is essential for the Fast Refresh feature and for serving your JavaScript code to the app. ```sh # Using npm npm start # OR using Yarn yarn start ``` -------------------------------- ### Basic Native Crash Setup Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/usage/native-crash-handling.md Sets up the native exception handler with options to force app quit and control chaining of previous handlers. Use this for general native crash reporting. ```typescript import { setNativeExceptionHandler, } from 'react-native-global-exception-handler'; setNativeExceptionHandler((errorString) => { console.log('Native crash:', errorString); // forward to your monitoring service }, { forceAppToQuit: true, callPreviouslyDefinedHandler: false, }); ``` -------------------------------- ### Build and Run iOS App Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/example/README.md After installing CocoaPods dependencies, use this command to build and launch the iOS application. Ensure Metro is running. ```sh # Using npm npm run ios # OR using Yarn yarn ios ``` -------------------------------- ### Minimal Chained Native Handler Example Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/usage/native-crash-handling.md An example of setting up a native exception handler that also calls any previously defined native handler. This is useful when integrating with other native crash reporting SDKs. ```typescript setNativeExceptionHandler((errorString) => { console.log('Native error:', errorString); }, { forceAppToQuit: true, callPreviouslyDefinedHandler: true, }); ``` -------------------------------- ### Set Up Native Exception Handler Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/README.md Configure the native exception handler to catch errors. This setup includes an error callback and options to force the app to quit. ```javascript import { setNativeExceptionHandler } from 'react-native-global-exception-handler'; setNativeExceptionHandler((errorString) => { console.log('Native Exception:', errorString); // Send to crash reporting service }, { forceAppToQuit: true, callPreviouslyDefinedHandler: false, }); ``` -------------------------------- ### Complete Production Setup with Sentry Integration Source: https://context7.com/darshan09200/react-native-global-exception-handler/llms.txt This snippet demonstrates a full production wiring pattern for handling both JavaScript and native exceptions, integrating with Sentry. It should be placed in your `index.js` file before the root component is registered. Ensure you replace the Sentry DSN with your actual project's DSN. ```tsx // index.js import { AppRegistry, Alert } from 'react-native'; import * as Sentry from '@sentry/react-native'; import { setJSExceptionHandler, setNativeExceptionHandler, } from 'react-native-global-exception-handler'; import App from './App'; import { name as appName } from './app.json'; // 1. Initialize Sentry Sentry.init({ dsn: 'https://@sentry.io/' }); // 2. JavaScript handler — runs synchronously in the JS thread setJSExceptionHandler((error: Error, isFatal: boolean) => { Sentry.captureException(error); if (isFatal) { Alert.alert( 'Unexpected Error', 'Something went wrong. Please restart the app.', [{ text: 'OK' }] ); } }, false /* keep false for production; RedBox still shows in dev */); // 3. Native handler — runs at crash time; keep it minimal setNativeExceptionHandler( (exceptionString: string) => { // Sentry's native SDK usually captures this independently, // but you can log/persist it here as a belt-and-suspenders measure console.log('[Native Crash]', exceptionString); }, { forceAppToQuit: true, callPreviouslyDefinedHandler: true, // preserve any SDK-installed native handler } ); AppRegistry.registerComponent(appName, () => App); ``` -------------------------------- ### Verify JS and Native Exception Handlers Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/troubleshooting.md This example demonstrates how to set up both JavaScript and native exception handlers to verify that errors are being caught. Check console logs in your expected environment to confirm functionality before debugging monitoring providers. ```ts setJSExceptionHandler((error, isFatal) => { console.log('JS handler fired', error.message, isFatal); }, true); setNativeExceptionHandler((errorString) => { console.log('Native handler fired', errorString); }, { forceAppToQuit: true, }); ``` -------------------------------- ### Basic Native Crash Simulation Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/examples/simulate-native-crash-in-react-native.md Use this basic example to simulate a native crash of type `nsexception`. Ensure you have imported `CrashType` and `simulateNativeCrash` from the library. ```typescript import { CrashType, simulateNativeCrash, } from 'react-native-global-exception-handler'; simulateNativeCrash(CrashType.nsexception); ``` -------------------------------- ### Install the package using npm or yarn Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/overview/installation.md Use this command to add the package to your React Native project dependencies. It supports both npm and yarn package managers. ```bash npm install react-native-global-exception-handler ``` -------------------------------- ### Verify Native Handler Execution with AsyncStorage Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/advanced/testing.md Configure the native exception handler to log crash details to AsyncStorage for later verification. This example also shows how to report to an analytics service and then retrieve the logged data. ```javascript import AsyncStorage from '@react-native-async-storage/async-storage'; setNativeExceptionHandler(async (errorString) => { // Log locally for verification await AsyncStorage.setItem('lastNativeCrash', JSON.stringify({ error: errorString, timestamp: new Date().toISOString() })); // Send to analytics reportToAnalytics(errorString); }); // Later, check if handler was called AsyncStorage.getItem('lastNativeCrash').then(data => { if (data) { console.log('Last crash:', JSON.parse(data)); } }); ``` -------------------------------- ### Configure Chaining Native Handlers Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/migration/migrating-from-react-native-exception-handler.md When migrating, explicitly set `callPreviouslyDefinedHandler` to `true` if your previous setup involved chaining other native handlers. ```typescript setNativeExceptionHandler(handler, { forceAppToQuit: true, callPreviouslyDefinedHandler: true, }); ``` -------------------------------- ### Basic JavaScript and Native Exception Handling Setup Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/examples/basic-examples.md Sets up both JavaScript and native exception handlers. The JS handler displays an alert for fatal errors and logs non-fatal ones. The native handler logs the error string and can be configured to force the app to quit on Android. ```typescript import { setJSExceptionHandler, setNativeExceptionHandler } from 'react-native-global-exception-handler'; import { Alert, Platform } from 'react-native'; setJSExceptionHandler((error, isFatal) => { if (isFatal) { Alert.alert('Unexpected Error', `${error.name}: ${error.message}`, [{ text: 'OK' }]); } else { console.warn('Non-fatal JS error', error); } }, true); setNativeExceptionHandler((errorString) => { console.log('Native Exception:', errorString); }, { forceAppToQuit: Platform.OS === 'android', callPreviouslyDefinedHandler: false }); ``` -------------------------------- ### Fix CocoaPods Installation Failure Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/troubleshooting.md If CocoaPods cannot find compatible versions for the GlobalExceptionHandler pod, try reinstalling CocoaPods and cleaning the iOS project's Pods directory before running pod install again. ```text [!] CocoaPods could not find compatible versions for pod "GlobalExceptionHandler" ``` ```bash sudo gem install cocoapods cd ios rm -rf Pods Podfile.lock pod deintegrate pod install cd .. ``` -------------------------------- ### Lightweight Shared Exception Handling Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/examples/analytics-examples.md A basic setup for handling both JavaScript and native exceptions. It logs errors to the console and configures the native handler to force the app to quit. ```typescript import { setJSExceptionHandler, setNativeExceptionHandler, } from 'react-native-global-exception-handler'; setJSExceptionHandler((error, isFatal) => { console.log('report JS error', error.message, isFatal); }, true); setNativeExceptionHandler((errorString) => { console.log('report native error', errorString); }, { forceAppToQuit: true, callPreviouslyDefinedHandler: false, }); ``` -------------------------------- ### Recommended Production Pattern for Crashlytics Integration Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/examples/react-native-crashlytics-integration.md A comprehensive setup combining JavaScript and native exception handling with Crashlytics, using `setAttributes` for efficiency. Consider native handler constraints and Android restart logic. ```typescript import { Platform } from 'react-native'; import crashlytics from '@react-native-firebase/crashlytics'; import { setJSExceptionHandler, setNativeExceptionHandler, } from 'react-native-global-exception-handler'; setJSExceptionHandler((error, isFatal) => { crashlytics().recordError(error); crashlytics().setAttributes({ layer: 'javascript', is_fatal: String(isFatal), }); }, true); setNativeExceptionHandler((errorString) => { crashlytics().log(errorString); crashlytics().setAttributes({ layer: 'native', platform: Platform.OS, }); }, { forceAppToQuit: Platform.OS === 'android', callPreviouslyDefinedHandler: false, }); ``` -------------------------------- ### ExceptionHandlerOptions Examples Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/api.md Illustrates different configurations for `ExceptionHandlerOptions`. The 'Safer default' uses the library's default settings. 'Preserve an earlier native handler' enables calling existing handlers. 'Advanced Android-only recovery attempt' disables app quitting while still preserving native handlers. ```typescript // Safer default { forceAppToQuit: true, callPreviouslyDefinedHandler: false, } ``` ```typescript // Preserve an earlier native handler { forceAppToQuit: true, callPreviouslyDefinedHandler: true, } ``` ```typescript // Advanced Android-only recovery attempt { forceAppToQuit: false, callPreviouslyDefinedHandler: true, } ``` -------------------------------- ### setNativeExceptionHandler — Register a global native crash handler Source: https://context7.com/darshan09200/react-native-global-exception-handler/llms.txt Installs a native-side handler that fires when the OS detects a crash. The handler callback receives the crash description as a plain string. It should perform only minimal synchronous work. ```APIDOC ## setNativeExceptionHandler ### Description Installs a native-side handler that fires when the OS detects a crash (signal, NSException, etc.) on iOS or Android. The handler callback receives the crash description as a plain string. Because execution state is unreliable at crash time, the callback should do only minimal synchronous work—writing a log or setting a persisted flag—rather than UI updates or async operations. ### Method Signature `setNativeExceptionHandler(callback: (exceptionString: string) => void, options?: { forceAppToQuit?: boolean, callPreviouslyDefinedHandler?: boolean })` ### Parameters #### callback - `exceptionString` (string) - Description of the native crash. #### options - `forceAppToQuit` (boolean) - Optional. On Android, forces the app to quit after the handler runs. Defaults to `true`. - `callPreviouslyDefinedHandler` (boolean) - Optional. Chains the previously registered native handler. Defaults to `false`. ### Request Example ```tsx import { setNativeExceptionHandler } from 'react-native-global-exception-handler'; setNativeExceptionHandler( (exceptionString: string) => { console.log('Native crash intercepted:', exceptionString); }, { forceAppToQuit: true, callPreviouslyDefinedHandler: true, } ); ``` ``` -------------------------------- ### Android Native Crash Handler Configuration Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/usage/native-crash-handling.md Configures the native exception handler for Android, demonstrating options for forcing app quit and chaining handlers. This setup allows for logging and potential app restart strategies. ```typescript setNativeExceptionHandler((errorString) => { console.log(errorString); }, { forceAppToQuit: true, callPreviouslyDefinedHandler: false, }); ``` -------------------------------- ### Build Static Website Content Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/README.md Generates static website files into the 'build' directory, ready for hosting. ```bash yarn build ``` -------------------------------- ### Get and Chain JavaScript Exception Handler Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/api.md Retrieve the current JavaScript exception handler to chain custom logic before or after it. This is useful for preserving existing handlers. ```typescript import { getJSExceptionHandler, setJSExceptionHandler, } from 'react-native-global-exception-handler'; const previousHandler = getJSExceptionHandler(); setJSExceptionHandler((error, isFatal) => { console.log('My handler', error.message); if (previousHandler) { previousHandler(error, isFatal); } }, true); ``` -------------------------------- ### Publish New Versions Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/CONTRIBUTING.md Uses release-it to manage version bumping, tagging, and publishing to npm. ```sh yarn release ``` -------------------------------- ### Initialize Sentry Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/examples/react-native-sentry-integration.md Initialize Sentry in your app's entry point before registering exception handlers. Ensure your DSN is correctly configured. ```typescript import * as Sentry from '@sentry/react-native'; Sentry.init({ dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0', tracesSampleRate: 0.1, }); ``` -------------------------------- ### Retrieve and chain JavaScript exception handlers Source: https://context7.com/darshan09200/react-native-global-exception-handler/llms.txt Use getJSExceptionHandler to get the current handler, allowing you to chain new handlers with existing ones. This is useful for integrating with other SDKs that might have already set a handler. ```tsx import { getJSExceptionHandler, setJSExceptionHandler, } from 'react-native-global-exception-handler'; // Save the previously installed handler (e.g., set by another SDK) const previousHandler = getJSExceptionHandler(); setJSExceptionHandler((error: Error, isFatal: boolean) => { // Forward to your own reporting first myReportingService.captureException(error, { level: isFatal ? 'fatal' : 'warning' }); // Then call the original handler so the previous SDK still works if (previousHandler) { previousHandler(error, isFatal); } }, false); ``` -------------------------------- ### Minimal Native Handler Configuration Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/examples/basic-examples.md Shows the minimal configuration for setting a native exception handler using an object for options, ensuring the app quits and does not call previously defined handlers. ```javascript setNativeExceptionHandler(handlerFn, { forceAppToQuit: true, callPreviouslyDefinedHandler: false }); ``` -------------------------------- ### Build Production Bundle for Testing Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/advanced/testing.md Commands to build a release version of your React Native application for iOS and Android. This is necessary to test the native exception handler, which is inactive in development mode. ```bash # iOS npx react-native run-ios --configuration Release # Android npx react-native run-android --variant=release ``` -------------------------------- ### Deploy Website using SSH Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/README.md Deploys the website using SSH, typically for pushing to a 'gh-pages' branch on GitHub. ```bash USE_SSH=true yarn deploy ``` -------------------------------- ### Deploy Website without SSH Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/README.md Deploys the website without using SSH. Replace '' with your actual GitHub username. ```bash GIT_USER= yarn deploy ``` -------------------------------- ### Restart App After Fatal JS Error Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/examples/advanced-examples.md Implement app restart for fatal JavaScript errors using `react-native-restart`. This provides users a fresh start after an unexpected crash. The native handler also supports restarting on Android. ```bash npm install react-native-restart ``` ```typescript import { Platform, Alert } from 'react-native'; import RNRestart from 'react-native-restart'; import { setJSExceptionHandler, setNativeExceptionHandler } from 'react-native-global-exception-handler'; setJSExceptionHandler ((error, isFatal) => { if (isFatal) { Alert.alert( 'Unexpected error occurred', ` Error: ${isFatal ? 'Fatal' : ''} ${error.name} ${error.message} We will need to restart the app. `, [ { text: 'Restart', onPress: () => { RNRestart.Restart(); }, }, ] ); } }); setNativeExceptionHandler((errorString) => { //You can do something like call an api to report to dev team here ... ... // When you call setNativeExceptionHandler, react-native-global-exception-handler sets a // Native Exception Handler popup which supports restart on error in case of android. // In case of iOS, it is not possible to restart the app programmatically, so we just show an error popup and close the app. // To customize the popup screen take a look at CUSTOMIZATION section. }, { forceAppToQuit: true }); ``` -------------------------------- ### Run Unit Tests Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/CONTRIBUTING.md Executes the unit tests for the project using Jest. ```sh yarn test ``` -------------------------------- ### Simulate JavaScript Error Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/advanced/testing.md Set up the JS exception handler and then throw an error to test its functionality. Ensure the handler is configured before the error is thrown. ```javascript import { setJSExceptionHandler } from 'react-native-global-exception-handler'; setJSExceptionHandler((error, isFatal) => { console.log('JS Exception:', error, isFatal); }, true); // Somewhere in your code throw new Error('Test JS Error'); ``` -------------------------------- ### Build and Run Android App Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/example/README.md Execute this command in a separate terminal from your React Native project's root directory to build and launch the Android application. Ensure Metro is running. ```sh # Using npm npm run android # OR using Yarn yarn android ``` -------------------------------- ### Lint Code with ESLint Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/CONTRIBUTING.md Runs ESLint to check for code style and potential errors. ```sh yarn lint ``` -------------------------------- ### Default ExceptionHandlerOptions Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/api.md Shows the default values for `forceAppToQuit` and `callPreviouslyDefinedHandler` when no options are explicitly provided. ```typescript { forceAppToQuit: true, callPreviouslyDefinedHandler: false } ``` -------------------------------- ### Register Native Exception Handler with Options Source: https://context7.com/darshan09200/react-native-global-exception-handler/llms.txt Use this preferred API to register a native-side handler for OS-detected crashes. The callback should perform minimal synchronous work. Options can control app quitting behavior and chaining previous handlers. ```tsx import { setNativeExceptionHandler } from 'react-native-global-exception-handler'; // Preferred API — options object setNativeExceptionHandler( (exceptionString: string) => { // Synchronous-only work: write to AsyncStorage/MMKV, log to console console.log('Native crash intercepted:', exceptionString); // Forward to a crash reporting SDK that supports synchronous reporting // e.g., Crashlytics.recordError(new Error(exceptionString)); }, { forceAppToQuit: true, // Android: terminate after handler callPreviouslyDefinedHandler: true, // iOS & Android: chain previous handler } ); ``` -------------------------------- ### Chaining Previous JavaScript Exception Handler Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/examples/basic-examples.md Demonstrates how to chain a new JavaScript exception handler with a previously defined one using `getJSExceptionHandler` and `setJSExceptionHandler`. ```typescript import { setJSExceptionHandler, getJSExceptionHandler } from 'react-native-global-exception-handler'; const prev = getJSExceptionHandler(); setJSExceptionHandler((e, fatal) => { // custom logic if (prev) prev(e, fatal); }); ``` -------------------------------- ### Create Custom Error Activity (Android) Source: https://github.com/darshan09200/react-native-global-exception-handler/blob/main/website/docs/advanced/customization.md Define a custom Activity to replace the default native error screen. This involves creating the Activity, its layout, and registering it with the `GlobalExceptionHandlerModule`. ```kotlin import android.app.Activity import android.os.Bundle import android.widget.Button import android.widget.TextView class CustomErrorActivity : Activity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_custom_error) // Get error message from intent val errorMessage = intent.getStringExtra("error") findViewById(R.id.errorText).text = errorMessage findViewById