-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathErrorHandleUtils.ts
More file actions
45 lines (40 loc) · 1.09 KB
/
ErrorHandleUtils.ts
File metadata and controls
45 lines (40 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { Alert } from "react-native";
import RNRestart from 'react-native-restart';
export function handleApiError(error?: any) {
Alert.alert("Error", error?.error || error)
}
function isDisplayError(message: string) {
switch (message) {
case "Nothing to display":
return false;
case "Unauthorized":
return false;
case "403":
return false;
case "":
return false;
default:
return true;
}
}
export const exceptionHandler = (error: any, isFatal: boolean) => {
if (isFatal) {
Alert.alert(
'Our dev team is working on this',
" We will need to restart the app."
,
[{
text: 'Restart',
onPress: () => {
RNRestart.Restart();
}
}],
{ cancelable: false },
);
} else if (error !== undefined) {
console.log(JSON.stringify(error));
}
};
export const nativeExceptionHandler = (exceptionString: string) => {
RNRestart.Restart();
};