Skip to content

Commit 1359c16

Browse files
Prettify file.
1 parent a1a03f2 commit 1359c16

1 file changed

Lines changed: 19 additions & 26 deletions

File tree

utils/globalErrorhandler.ts

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,25 @@
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';
74

85
// JavaScript Error Handler
96
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 });
1310

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);
2114

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+
);
3225
};

0 commit comments

Comments
 (0)