Skip to content

Commit 0081e5f

Browse files
authored
Merge pull request #23 from lexor90/master
Fix Android parameters ordering
2 parents 26f57c6 + 10728e9 commit 0081e5f

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

android/src/main/java/com/masteratul/exceptionhandler/ReactNativeExceptionHandlerModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public String getName() {
2828

2929

3030
@ReactMethod
31-
public void setHandlerforNativeException(Callback customHandler, final boolean forceToQuit){
31+
public void setHandlerforNativeException(final boolean forceToQuit, Callback customHandler){
3232
callbackHolder = customHandler;
3333

3434
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {

index.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,28 @@ export const setJSExceptionHandler = (customHandler = noop, allowedInDevMode = f
1717

1818
export const getJSExceptionHandler = () => global.ErrorUtils.getGlobalHandler();
1919

20-
export const setNativeExceptionHandler = (customErrorHandler = noop, forceApplicationToQuit = true) => {
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+
2134
if (typeof customErrorHandler !== 'function') {
2235
customErrorHandler = noop;
2336
}
2437

2538
if (Platform.OS === 'ios') {
2639
ReactNativeExceptionHandler.setHandlerforNativeException(customErrorHandler);
2740
} else {
28-
ReactNativeExceptionHandler.setHandlerforNativeException(customErrorHandler, forceApplicationToQuit);
41+
ReactNativeExceptionHandler.setHandlerforNativeException(forceApplicationToQuit, customErrorHandler);
2942
}
3043
};
3144

0 commit comments

Comments
 (0)