Skip to content

Commit bd3650a

Browse files
committed
Added 2.6.0 and removed backward compatible code and added warning to console.log
1 parent 47be0a8 commit bd3650a

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

index.js

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ const {ReactNativeExceptionHandler} = NativeModules;
66
const noop = () => {};
77

88
export const setJSExceptionHandler = (customHandler = noop, allowedInDevMode = false) => {
9+
if ((typeof allowedInDevMode !== 'boolean') || (typeof customHandler !== 'function')) {
10+
console.log('setJSExceptionHandler is called with wrong argument types.. first argument should be callback function and second argument is optional should be a boolean');
11+
console.log('Not setting the JS handler .. please fix setJSExceptionHandler call');
12+
return;
13+
}
914
const allowed = allowedInDevMode ? true : !__DEV__;
1015
if (allowed) {
1116
global.ErrorUtils.setGlobalHandler(customHandler);
@@ -17,24 +22,12 @@ export const setJSExceptionHandler = (customHandler = noop, allowedInDevMode = f
1722

1823
export const getJSExceptionHandler = () => global.ErrorUtils.getGlobalHandler();
1924

20-
export const setNativeExceptionHandler = (forceApplicationToQuit = true, customErrorHandler = noop) => {
21-
var handler = customErrorHandler;
22-
23-
// backward compatible API
24-
if (typeof forceApplicationToQuit === 'function') {
25-
handler = forceApplicationToQuit;
26-
}
27-
28-
if (typeof customErrorHandler === 'boolean') {
29-
forceApplicationToQuit = customErrorHandler;
30-
}
31-
32-
customErrorHandler = handler;
33-
34-
if (typeof customErrorHandler !== 'function') {
35-
customErrorHandler = noop;
25+
export const setNativeExceptionHandler = (customErrorHandler = noop, forceApplicationToQuit = true) => {
26+
if ((typeof customErrorHandler !== 'function') || (typeof forceApplicationToQuit !== 'boolean')) {
27+
console.log('setNativeExceptionHandler is called with wrong argument types.. first argument should be callback function and second argument is optional should be a boolean');
28+
console.log('Not setting the native handler .. please fix setNativeExceptionHandler call');
29+
return;
3630
}
37-
3831
if (Platform.OS === 'ios') {
3932
ReactNativeExceptionHandler.setHandlerforNativeException(customErrorHandler);
4033
} else {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-exception-handler",
3-
"version": "2.4.3",
3+
"version": "2.6.0",
44
"description": "A react native module that lets you to register a global error handler that can capture fatal/non fatal uncaught exceptions.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)