Skip to content

Commit be9aa66

Browse files
author
Zeh Fernando
committed
Added documentation for the third parameter, keepPreviousHandler
1 parent 3a3a44b commit be9aa66

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# react-native-exception-handler
22

33
A react native module that lets you to register a global error handler that can capture fatal/non fatal uncaught exceptions.
4-
The module helps prevent abrupt crashing of RN Apps without a graceful message to the user.
4+
The module helps prevent abrupt crashing of RN Apps without a graceful message to the user.
55

66
In the current scenario:
77
- `In DEV mode , you get a RED Screen error pointing your JS errors.`
@@ -46,9 +46,14 @@ setJSExceptionHandler(errorHandler); // registering the error handler (maybe u c
4646
or
4747

4848
setJSExceptionHandler(errorHandler, true); //Second argument true is basically
49-
//if u need the handler to be called in place of RED
49+
//if u need the handler to be called in place of RED
5050
//screen in development mode also
51-
```
51+
or
52+
53+
setJSExceptionHandler(errorHandler, true, true); //Third argument allows adding it
54+
//as a new handler, but keeping the previous one
55+
//(it will run errorHandler but still show the red screen)
56+
```
5257

5358

5459
### Screens

examples/bugCaptureOnError.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {Alert} from 'react-native';
2-
import {BackAndroid} from 'react-native';
32
import {setJSExceptionHandler} from 'react-native-exception-handler';
43

54
const reporter = (error) => {

examples/seamlessCapture.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {setJSExceptionHandler} from 'react-native-exception-handler';
2+
3+
const reporter = (error) => {
4+
// Logic for reporting to devs
5+
// Example : Log issues to github issues using github apis.
6+
console.log(error); // sample
7+
};
8+
9+
const errorHandler = (e, isFatal) => {
10+
if (isFatal) {
11+
reporter(e);
12+
} else {
13+
console.log(e); // So that we can see it in the ADB logs in case of Android if needed
14+
}
15+
};
16+
17+
// We will still see the error screen, but our reporter() function will be called
18+
setJSExceptionHandler(errorHandler, false, true);

0 commit comments

Comments
 (0)