|
1 | | -import { |
2 | | - setJSExceptionHandler, |
3 | | - setNativeExceptionHandler, |
4 | | -} from "react-native-exception-handler"; |
5 | | -import { Alert } from "react-native"; |
6 | | -import { reportError } from "../services/errorReporting.service"; |
| 1 | +import { setJSExceptionHandler, setNativeExceptionHandler } from 'react-native-exception-handler'; |
| 2 | +import { reportError } from '../services/errorReporting.service'; |
| 3 | +import { notifyError } from '@/services/notifier.service'; |
7 | 4 |
|
8 | 5 | // JavaScript Error Handler |
9 | 6 | export const setupGlobalErrorHandlers = () => { |
10 | | - setJSExceptionHandler((error, isFatal) => { |
11 | | - // Report the error using your actual reportError function |
12 | | - reportError(error, { isFatal }); |
| 7 | + setJSExceptionHandler((error, isFatal) => { |
| 8 | + // Report the error using your actual reportError function |
| 9 | + reportError(error, { isFatal }); |
13 | 10 |
|
14 | | - // Show a friendly message instead of crashing |
15 | | - Alert.alert( |
16 | | - "Unexpected Error Occurred", |
17 | | - "We encountered an issue. The app will continue running, and our team has been notified.", |
18 | | - [{ text: "OK" }] |
19 | | - ); |
20 | | - }, true); |
| 11 | + // Show a non-blocking stacked banner instead of a modal alert |
| 12 | + notifyError(error, 'We encountered an issue. The app will continue running, and our team has been notified.'); |
| 13 | + }, true); |
21 | 14 |
|
22 | | - // Native Exception Handler |
23 | | - setNativeExceptionHandler( |
24 | | - (exceptionString) => { |
25 | | - // This is called when native code throws an exception |
26 | | - const error = new Error(`Native Exception: ${exceptionString}`); |
27 | | - reportError(error, { isFatal: true }); |
28 | | - }, |
29 | | - false, // don't force app to quit |
30 | | - true // should catch all exceptions |
31 | | - ); |
| 15 | + // Native Exception Handler |
| 16 | + setNativeExceptionHandler( |
| 17 | + (exceptionString) => { |
| 18 | + // This is called when native code throws an exception |
| 19 | + const error = new Error(`Native Exception: ${exceptionString}`); |
| 20 | + reportError(error, { isFatal: true }); |
| 21 | + }, |
| 22 | + false, // don't force app to quit |
| 23 | + true // should catch all exceptions |
| 24 | + ); |
32 | 25 | }; |
0 commit comments