@applica-software-guru/react-admin 1.3.130 → 1.3.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev/useErrorEventCatcher.d.ts.map +1 -1
- package/dist/react-admin.cjs.js +1 -1
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +252 -250
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +1 -1
- package/dist/react-admin.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/ApplicaAdmin.tsx +2 -2
- package/src/dev/useErrorEventCatcher.ts +16 -5
package/package.json
CHANGED
package/src/ApplicaAdmin.tsx
CHANGED
|
@@ -163,7 +163,7 @@ const ApplicaAdmin = ({
|
|
|
163
163
|
useErrorEventCatcher({
|
|
164
164
|
apiUrl,
|
|
165
165
|
errorHandler,
|
|
166
|
-
catcherFn: (error:
|
|
166
|
+
catcherFn: (error: ErrorEvent | string): CatchResult => {
|
|
167
167
|
const errorMessage = error?.toString();
|
|
168
168
|
const knownErrors = [
|
|
169
169
|
// @see https://github.com/marmelab/react-admin/pull/8884
|
|
@@ -177,7 +177,7 @@ const ApplicaAdmin = ({
|
|
|
177
177
|
catch: isKnowBug,
|
|
178
178
|
display: !isKnowBug,
|
|
179
179
|
log: !isKnowBug,
|
|
180
|
-
error
|
|
180
|
+
error: errorMessage
|
|
181
181
|
});
|
|
182
182
|
return result;
|
|
183
183
|
}
|
|
@@ -26,23 +26,34 @@ const useErrorEventCatcher = ({
|
|
|
26
26
|
}
|
|
27
27
|
return new ErrorEventHandler({ apiUrl });
|
|
28
28
|
}, [apiUrl, props.errorHandler]);
|
|
29
|
+
const consoleError = console.error;
|
|
29
30
|
const handleError = React.useCallback(
|
|
30
|
-
function (event: ErrorEvent) {
|
|
31
|
-
const catchResult = catcherFn(event);
|
|
32
|
-
|
|
31
|
+
function (event: ErrorEvent | string, ...args: any[]) {
|
|
32
|
+
const catchResult = catcherFn(event instanceof ErrorEvent ? event : event.replace(/%s/g, () => args.shift()));
|
|
33
|
+
if (catchResult.isCatched()) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
33
36
|
if (catchResult.logError()) {
|
|
34
|
-
|
|
37
|
+
if (event instanceof ErrorEvent) {
|
|
38
|
+
errorHandler.handle(event);
|
|
39
|
+
} else {
|
|
40
|
+
errorHandler.handle(new ErrorEvent('window.onerror', { error: event, message: event.toString() }));
|
|
41
|
+
}
|
|
35
42
|
}
|
|
36
43
|
|
|
37
|
-
|
|
44
|
+
if (catchResult.displayError()) {
|
|
45
|
+
consoleError.apply(console, arguments as any);
|
|
46
|
+
}
|
|
38
47
|
},
|
|
39
48
|
[apiUrl, loading, catcherFn, enabled, errorHandler]
|
|
40
49
|
);
|
|
41
50
|
React.useEffect(() => {
|
|
42
51
|
window.removeEventListener('error', handleError);
|
|
43
52
|
window.addEventListener('error', handleError);
|
|
53
|
+
console.error = handleError;
|
|
44
54
|
return () => {
|
|
45
55
|
window.removeEventListener('error', handleError);
|
|
56
|
+
console.error = consoleError;
|
|
46
57
|
};
|
|
47
58
|
}, [handleError]);
|
|
48
59
|
return true;
|