Skip to content

Commit f7bac35

Browse files
committed
added more readme doc
1 parent c4785de commit f7bac35

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ import {setJSExceptionHandler, getJSExceptionHandler} from 'react-native-excepti
120120

121121
.
122122
.
123-
123+
// For most use cases:
124124
// registering the error handler (maybe u can do this in the index.android.js or index.ios.js)
125125
setJSExceptionHandler((error, isFatal) => {
126126
// This is your custom global error handler
@@ -129,6 +129,16 @@ setJSExceptionHandler((error, isFatal) => {
129129
// or hit a custom api to inform the dev team.
130130
});
131131

132+
// ADVANCED use case:
133+
const exceptionhandler = (error, isFatal) => {
134+
// your error handler function
135+
};
136+
setJSExceptionHandler(exceptionhandler, allowInDevMode);
137+
// - exceptionhandler is the exception handler function
138+
// - allowInDevMode is an optional parameter is a boolean.
139+
// If set to true the handler to be called in place of RED screen
140+
// in development mode also.
141+
132142
// getJSExceptionHandler gives the currently set JS exception handler
133143
const currentHandler = getJSExceptionHandler();
134144
```
@@ -138,6 +148,7 @@ To catch **Native_Exceptions**
138148
```js
139149
import {setNativeExceptionHandler} from 'react-native-exception-handler';
140150

151+
//For most use cases:
141152
setNativeExceptionHandler((exceptionString) => {
142153
// This is your custom global error handler
143154
// You do stuff likehit google analytics to track crashes.
@@ -146,6 +157,16 @@ setNativeExceptionHandler((exceptionString) => {
146157
//WILL NOT WORK in case of NATIVE ERRORS.
147158
});
148159

160+
// ADVANCED use case:
161+
const exceptionhandler = (exceptionString) => {
162+
// your exception handler code here
163+
}
164+
setNativeExceptionHandler(exceptionhandler,forceAppQuit);
165+
// - exceptionhandler is the exception handler function
166+
// - forceAppQuit is an optional ANDROID specific parameter that defines
167+
// if the app should be force quit on error. default value is true.
168+
// To see usecase check the common issues section.
169+
149170
```
150171
It is recommended you set both the handlers.
151172

0 commit comments

Comments
 (0)