1 | import { Platform } from '@unimodules/core';
|
2 |
|
3 | import { getRecoveryPropsToSave } from './ErroRecoveryStore';
|
4 | import ExpoErrorRecovery from './ExpoErrorRecovery';
|
5 |
|
6 | if (Platform.OS !== 'web') {
|
7 | const globalHandler = ErrorUtils.getGlobalHandler();
|
8 |
|
9 |
|
10 | ErrorUtils.setGlobalHandler(async (error, isFatal) => {
|
11 | if (ExpoErrorRecovery.saveRecoveryProps) {
|
12 | await ExpoErrorRecovery.saveRecoveryProps(getRecoveryPropsToSave());
|
13 | }
|
14 | globalHandler(error, isFatal);
|
15 | });
|
16 | } else if (Platform.OS === 'web' && Platform.isDOMAvailable) {
|
17 | window.addEventListener('error', () => {
|
18 | ExpoErrorRecovery.saveRecoveryProps(getRecoveryPropsToSave());
|
19 | });
|
20 | }
|