@xyo-network/react-error 2.81.10 → 2.83.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/browser/index.d.ts +62 -3
- package/dist/browser/index.mjs +163 -0
- package/dist/browser/index.mjs.map +1 -0
- package/package.json +15 -31
- package/src/components/ErrorBoundary/ThrownErrorBoundary.stories.tsx +8 -4
- package/src/components/ErrorBoundary/ThrownErrorBoundary.tsx +5 -5
- package/src/components/ErrorBoundary/index.ts +1 -1
- package/src/components/ErrorRender/ErrorAlert.stories.tsx +1 -2
- package/src/components/ErrorRender/ErrorAlert.tsx +18 -14
- package/src/components/ErrorRender/Render.tsx +15 -12
- package/src/components/ErrorRender/index.ts +3 -3
- package/src/components/index.ts +2 -2
- package/src/contexts/ErrorReporter/Context.ts +1 -1
- package/src/contexts/ErrorReporter/Provider.stories.tsx +11 -4
- package/src/contexts/ErrorReporter/Provider.tsx +3 -2
- package/src/contexts/ErrorReporter/index.ts +3 -3
- package/src/contexts/ErrorReporter/useRollbar.tsx +1 -1
- package/src/contexts/index.ts +1 -1
- package/src/index.ts +2 -2
- package/xy.config.ts +12 -0
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.cts +0 -23
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.cts.map +0 -1
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.mts +0 -23
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.mts.map +0 -1
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.ts +0 -23
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.ts.map +0 -1
- package/dist/browser/components/ErrorBoundary/index.d.cts +0 -2
- package/dist/browser/components/ErrorBoundary/index.d.cts.map +0 -1
- package/dist/browser/components/ErrorBoundary/index.d.mts +0 -2
- package/dist/browser/components/ErrorBoundary/index.d.mts.map +0 -1
- package/dist/browser/components/ErrorBoundary/index.d.ts +0 -2
- package/dist/browser/components/ErrorBoundary/index.d.ts.map +0 -1
- package/dist/browser/components/ErrorRender/ErrorAlert.d.cts +0 -10
- package/dist/browser/components/ErrorRender/ErrorAlert.d.cts.map +0 -1
- package/dist/browser/components/ErrorRender/ErrorAlert.d.mts +0 -10
- package/dist/browser/components/ErrorRender/ErrorAlert.d.mts.map +0 -1
- package/dist/browser/components/ErrorRender/ErrorAlert.d.ts +0 -10
- package/dist/browser/components/ErrorRender/ErrorAlert.d.ts.map +0 -1
- package/dist/browser/components/ErrorRender/Props.d.cts +0 -15
- package/dist/browser/components/ErrorRender/Props.d.cts.map +0 -1
- package/dist/browser/components/ErrorRender/Props.d.mts +0 -15
- package/dist/browser/components/ErrorRender/Props.d.mts.map +0 -1
- package/dist/browser/components/ErrorRender/Props.d.ts +0 -15
- package/dist/browser/components/ErrorRender/Props.d.ts.map +0 -1
- package/dist/browser/components/ErrorRender/Render.d.cts +0 -3
- package/dist/browser/components/ErrorRender/Render.d.cts.map +0 -1
- package/dist/browser/components/ErrorRender/Render.d.mts +0 -3
- package/dist/browser/components/ErrorRender/Render.d.mts.map +0 -1
- package/dist/browser/components/ErrorRender/Render.d.ts +0 -3
- package/dist/browser/components/ErrorRender/Render.d.ts.map +0 -1
- package/dist/browser/components/ErrorRender/index.d.cts +0 -4
- package/dist/browser/components/ErrorRender/index.d.cts.map +0 -1
- package/dist/browser/components/ErrorRender/index.d.mts +0 -4
- package/dist/browser/components/ErrorRender/index.d.mts.map +0 -1
- package/dist/browser/components/ErrorRender/index.d.ts +0 -4
- package/dist/browser/components/ErrorRender/index.d.ts.map +0 -1
- package/dist/browser/components/index.d.cts +0 -3
- package/dist/browser/components/index.d.cts.map +0 -1
- package/dist/browser/components/index.d.mts +0 -3
- package/dist/browser/components/index.d.mts.map +0 -1
- package/dist/browser/components/index.d.ts +0 -3
- package/dist/browser/components/index.d.ts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/Context.d.cts +0 -3
- package/dist/browser/contexts/ErrorReporter/Context.d.cts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/Context.d.mts +0 -3
- package/dist/browser/contexts/ErrorReporter/Context.d.mts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/Context.d.ts +0 -3
- package/dist/browser/contexts/ErrorReporter/Context.d.ts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/Provider.d.cts +0 -8
- package/dist/browser/contexts/ErrorReporter/Provider.d.cts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/Provider.d.mts +0 -8
- package/dist/browser/contexts/ErrorReporter/Provider.d.mts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/Provider.d.ts +0 -8
- package/dist/browser/contexts/ErrorReporter/Provider.d.ts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/State.d.cts +0 -5
- package/dist/browser/contexts/ErrorReporter/State.d.cts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/State.d.mts +0 -5
- package/dist/browser/contexts/ErrorReporter/State.d.mts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/State.d.ts +0 -5
- package/dist/browser/contexts/ErrorReporter/State.d.ts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/index.d.cts +0 -4
- package/dist/browser/contexts/ErrorReporter/index.d.cts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/index.d.mts +0 -4
- package/dist/browser/contexts/ErrorReporter/index.d.mts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/index.d.ts +0 -4
- package/dist/browser/contexts/ErrorReporter/index.d.ts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/useRollbar.d.cts +0 -3
- package/dist/browser/contexts/ErrorReporter/useRollbar.d.cts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/useRollbar.d.mts +0 -3
- package/dist/browser/contexts/ErrorReporter/useRollbar.d.mts.map +0 -1
- package/dist/browser/contexts/ErrorReporter/useRollbar.d.ts +0 -3
- package/dist/browser/contexts/ErrorReporter/useRollbar.d.ts.map +0 -1
- package/dist/browser/contexts/index.d.cts +0 -2
- package/dist/browser/contexts/index.d.cts.map +0 -1
- package/dist/browser/contexts/index.d.mts +0 -2
- package/dist/browser/contexts/index.d.mts.map +0 -1
- package/dist/browser/contexts/index.d.ts +0 -2
- package/dist/browser/contexts/index.d.ts.map +0 -1
- package/dist/browser/index.cjs +0 -153
- package/dist/browser/index.cjs.map +0 -1
- package/dist/browser/index.d.cts +0 -3
- package/dist/browser/index.d.cts.map +0 -1
- package/dist/browser/index.d.mts +0 -3
- package/dist/browser/index.d.mts.map +0 -1
- package/dist/browser/index.d.ts.map +0 -1
- package/dist/browser/index.js +0 -130
- package/dist/browser/index.js.map +0 -1
- package/dist/neutral/components/ErrorBoundary/ThrownErrorBoundary.d.cts +0 -23
- package/dist/neutral/components/ErrorBoundary/ThrownErrorBoundary.d.cts.map +0 -1
- package/dist/neutral/components/ErrorBoundary/ThrownErrorBoundary.d.mts +0 -23
- package/dist/neutral/components/ErrorBoundary/ThrownErrorBoundary.d.mts.map +0 -1
- package/dist/neutral/components/ErrorBoundary/ThrownErrorBoundary.d.ts +0 -23
- package/dist/neutral/components/ErrorBoundary/ThrownErrorBoundary.d.ts.map +0 -1
- package/dist/neutral/components/ErrorBoundary/index.d.cts +0 -2
- package/dist/neutral/components/ErrorBoundary/index.d.cts.map +0 -1
- package/dist/neutral/components/ErrorBoundary/index.d.mts +0 -2
- package/dist/neutral/components/ErrorBoundary/index.d.mts.map +0 -1
- package/dist/neutral/components/ErrorBoundary/index.d.ts +0 -2
- package/dist/neutral/components/ErrorBoundary/index.d.ts.map +0 -1
- package/dist/neutral/components/ErrorRender/ErrorAlert.d.cts +0 -10
- package/dist/neutral/components/ErrorRender/ErrorAlert.d.cts.map +0 -1
- package/dist/neutral/components/ErrorRender/ErrorAlert.d.mts +0 -10
- package/dist/neutral/components/ErrorRender/ErrorAlert.d.mts.map +0 -1
- package/dist/neutral/components/ErrorRender/ErrorAlert.d.ts +0 -10
- package/dist/neutral/components/ErrorRender/ErrorAlert.d.ts.map +0 -1
- package/dist/neutral/components/ErrorRender/Props.d.cts +0 -15
- package/dist/neutral/components/ErrorRender/Props.d.cts.map +0 -1
- package/dist/neutral/components/ErrorRender/Props.d.mts +0 -15
- package/dist/neutral/components/ErrorRender/Props.d.mts.map +0 -1
- package/dist/neutral/components/ErrorRender/Props.d.ts +0 -15
- package/dist/neutral/components/ErrorRender/Props.d.ts.map +0 -1
- package/dist/neutral/components/ErrorRender/Render.d.cts +0 -3
- package/dist/neutral/components/ErrorRender/Render.d.cts.map +0 -1
- package/dist/neutral/components/ErrorRender/Render.d.mts +0 -3
- package/dist/neutral/components/ErrorRender/Render.d.mts.map +0 -1
- package/dist/neutral/components/ErrorRender/Render.d.ts +0 -3
- package/dist/neutral/components/ErrorRender/Render.d.ts.map +0 -1
- package/dist/neutral/components/ErrorRender/index.d.cts +0 -4
- package/dist/neutral/components/ErrorRender/index.d.cts.map +0 -1
- package/dist/neutral/components/ErrorRender/index.d.mts +0 -4
- package/dist/neutral/components/ErrorRender/index.d.mts.map +0 -1
- package/dist/neutral/components/ErrorRender/index.d.ts +0 -4
- package/dist/neutral/components/ErrorRender/index.d.ts.map +0 -1
- package/dist/neutral/components/index.d.cts +0 -3
- package/dist/neutral/components/index.d.cts.map +0 -1
- package/dist/neutral/components/index.d.mts +0 -3
- package/dist/neutral/components/index.d.mts.map +0 -1
- package/dist/neutral/components/index.d.ts +0 -3
- package/dist/neutral/components/index.d.ts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/Context.d.cts +0 -3
- package/dist/neutral/contexts/ErrorReporter/Context.d.cts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/Context.d.mts +0 -3
- package/dist/neutral/contexts/ErrorReporter/Context.d.mts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/Context.d.ts +0 -3
- package/dist/neutral/contexts/ErrorReporter/Context.d.ts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/Provider.d.cts +0 -8
- package/dist/neutral/contexts/ErrorReporter/Provider.d.cts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/Provider.d.mts +0 -8
- package/dist/neutral/contexts/ErrorReporter/Provider.d.mts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/Provider.d.ts +0 -8
- package/dist/neutral/contexts/ErrorReporter/Provider.d.ts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/State.d.cts +0 -5
- package/dist/neutral/contexts/ErrorReporter/State.d.cts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/State.d.mts +0 -5
- package/dist/neutral/contexts/ErrorReporter/State.d.mts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/State.d.ts +0 -5
- package/dist/neutral/contexts/ErrorReporter/State.d.ts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/index.d.cts +0 -4
- package/dist/neutral/contexts/ErrorReporter/index.d.cts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/index.d.mts +0 -4
- package/dist/neutral/contexts/ErrorReporter/index.d.mts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/index.d.ts +0 -4
- package/dist/neutral/contexts/ErrorReporter/index.d.ts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/useRollbar.d.cts +0 -3
- package/dist/neutral/contexts/ErrorReporter/useRollbar.d.cts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/useRollbar.d.mts +0 -3
- package/dist/neutral/contexts/ErrorReporter/useRollbar.d.mts.map +0 -1
- package/dist/neutral/contexts/ErrorReporter/useRollbar.d.ts +0 -3
- package/dist/neutral/contexts/ErrorReporter/useRollbar.d.ts.map +0 -1
- package/dist/neutral/contexts/index.d.cts +0 -2
- package/dist/neutral/contexts/index.d.cts.map +0 -1
- package/dist/neutral/contexts/index.d.mts +0 -2
- package/dist/neutral/contexts/index.d.mts.map +0 -1
- package/dist/neutral/contexts/index.d.ts +0 -2
- package/dist/neutral/contexts/index.d.ts.map +0 -1
- package/dist/neutral/index.cjs +0 -153
- package/dist/neutral/index.cjs.map +0 -1
- package/dist/neutral/index.d.cts +0 -3
- package/dist/neutral/index.d.cts.map +0 -1
- package/dist/neutral/index.d.mts +0 -3
- package/dist/neutral/index.d.mts.map +0 -1
- package/dist/neutral/index.d.ts +0 -3
- package/dist/neutral/index.d.ts.map +0 -1
- package/dist/neutral/index.js +0 -130
- package/dist/neutral/index.js.map +0 -1
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.cts +0 -23
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.cts.map +0 -1
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.mts +0 -23
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.mts.map +0 -1
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.ts +0 -23
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.ts.map +0 -1
- package/dist/node/components/ErrorBoundary/index.d.cts +0 -2
- package/dist/node/components/ErrorBoundary/index.d.cts.map +0 -1
- package/dist/node/components/ErrorBoundary/index.d.mts +0 -2
- package/dist/node/components/ErrorBoundary/index.d.mts.map +0 -1
- package/dist/node/components/ErrorBoundary/index.d.ts +0 -2
- package/dist/node/components/ErrorBoundary/index.d.ts.map +0 -1
- package/dist/node/components/ErrorRender/ErrorAlert.d.cts +0 -10
- package/dist/node/components/ErrorRender/ErrorAlert.d.cts.map +0 -1
- package/dist/node/components/ErrorRender/ErrorAlert.d.mts +0 -10
- package/dist/node/components/ErrorRender/ErrorAlert.d.mts.map +0 -1
- package/dist/node/components/ErrorRender/ErrorAlert.d.ts +0 -10
- package/dist/node/components/ErrorRender/ErrorAlert.d.ts.map +0 -1
- package/dist/node/components/ErrorRender/Props.d.cts +0 -15
- package/dist/node/components/ErrorRender/Props.d.cts.map +0 -1
- package/dist/node/components/ErrorRender/Props.d.mts +0 -15
- package/dist/node/components/ErrorRender/Props.d.mts.map +0 -1
- package/dist/node/components/ErrorRender/Props.d.ts +0 -15
- package/dist/node/components/ErrorRender/Props.d.ts.map +0 -1
- package/dist/node/components/ErrorRender/Render.d.cts +0 -3
- package/dist/node/components/ErrorRender/Render.d.cts.map +0 -1
- package/dist/node/components/ErrorRender/Render.d.mts +0 -3
- package/dist/node/components/ErrorRender/Render.d.mts.map +0 -1
- package/dist/node/components/ErrorRender/Render.d.ts +0 -3
- package/dist/node/components/ErrorRender/Render.d.ts.map +0 -1
- package/dist/node/components/ErrorRender/index.d.cts +0 -4
- package/dist/node/components/ErrorRender/index.d.cts.map +0 -1
- package/dist/node/components/ErrorRender/index.d.mts +0 -4
- package/dist/node/components/ErrorRender/index.d.mts.map +0 -1
- package/dist/node/components/ErrorRender/index.d.ts +0 -4
- package/dist/node/components/ErrorRender/index.d.ts.map +0 -1
- package/dist/node/components/index.d.cts +0 -3
- package/dist/node/components/index.d.cts.map +0 -1
- package/dist/node/components/index.d.mts +0 -3
- package/dist/node/components/index.d.mts.map +0 -1
- package/dist/node/components/index.d.ts +0 -3
- package/dist/node/components/index.d.ts.map +0 -1
- package/dist/node/contexts/ErrorReporter/Context.d.cts +0 -3
- package/dist/node/contexts/ErrorReporter/Context.d.cts.map +0 -1
- package/dist/node/contexts/ErrorReporter/Context.d.mts +0 -3
- package/dist/node/contexts/ErrorReporter/Context.d.mts.map +0 -1
- package/dist/node/contexts/ErrorReporter/Context.d.ts +0 -3
- package/dist/node/contexts/ErrorReporter/Context.d.ts.map +0 -1
- package/dist/node/contexts/ErrorReporter/Provider.d.cts +0 -8
- package/dist/node/contexts/ErrorReporter/Provider.d.cts.map +0 -1
- package/dist/node/contexts/ErrorReporter/Provider.d.mts +0 -8
- package/dist/node/contexts/ErrorReporter/Provider.d.mts.map +0 -1
- package/dist/node/contexts/ErrorReporter/Provider.d.ts +0 -8
- package/dist/node/contexts/ErrorReporter/Provider.d.ts.map +0 -1
- package/dist/node/contexts/ErrorReporter/State.d.cts +0 -5
- package/dist/node/contexts/ErrorReporter/State.d.cts.map +0 -1
- package/dist/node/contexts/ErrorReporter/State.d.mts +0 -5
- package/dist/node/contexts/ErrorReporter/State.d.mts.map +0 -1
- package/dist/node/contexts/ErrorReporter/State.d.ts +0 -5
- package/dist/node/contexts/ErrorReporter/State.d.ts.map +0 -1
- package/dist/node/contexts/ErrorReporter/index.d.cts +0 -4
- package/dist/node/contexts/ErrorReporter/index.d.cts.map +0 -1
- package/dist/node/contexts/ErrorReporter/index.d.mts +0 -4
- package/dist/node/contexts/ErrorReporter/index.d.mts.map +0 -1
- package/dist/node/contexts/ErrorReporter/index.d.ts +0 -4
- package/dist/node/contexts/ErrorReporter/index.d.ts.map +0 -1
- package/dist/node/contexts/ErrorReporter/useRollbar.d.cts +0 -3
- package/dist/node/contexts/ErrorReporter/useRollbar.d.cts.map +0 -1
- package/dist/node/contexts/ErrorReporter/useRollbar.d.mts +0 -3
- package/dist/node/contexts/ErrorReporter/useRollbar.d.mts.map +0 -1
- package/dist/node/contexts/ErrorReporter/useRollbar.d.ts +0 -3
- package/dist/node/contexts/ErrorReporter/useRollbar.d.ts.map +0 -1
- package/dist/node/contexts/index.d.cts +0 -2
- package/dist/node/contexts/index.d.cts.map +0 -1
- package/dist/node/contexts/index.d.mts +0 -2
- package/dist/node/contexts/index.d.mts.map +0 -1
- package/dist/node/contexts/index.d.ts +0 -2
- package/dist/node/contexts/index.d.ts.map +0 -1
- package/dist/node/index.cjs +0 -161
- package/dist/node/index.cjs.map +0 -1
- package/dist/node/index.d.cts +0 -3
- package/dist/node/index.d.cts.map +0 -1
- package/dist/node/index.d.mts +0 -3
- package/dist/node/index.d.mts.map +0 -1
- package/dist/node/index.d.ts +0 -3
- package/dist/node/index.d.ts.map +0 -1
- package/dist/node/index.js +0 -130
- package/dist/node/index.js.map +0 -1
package/dist/browser/index.d.ts
CHANGED
@@ -1,3 +1,62 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
2
|
+
import { ModuleError } from '@xyo-network/payload-model';
|
3
|
+
import React, { ReactNode, Component, ErrorInfo } from 'react';
|
4
|
+
import Rollbar from 'rollbar';
|
5
|
+
import { AlertProps } from '@mui/material';
|
6
|
+
import { FlexBoxProps } from '@xylabs/react-flexbox';
|
7
|
+
import { Location } from 'react-router-dom';
|
8
|
+
import { WithChildren } from '@xylabs/react-shared';
|
9
|
+
|
10
|
+
interface ThrownErrorBoundaryProps {
|
11
|
+
boundaryName?: string;
|
12
|
+
children: ReactNode;
|
13
|
+
errorComponent?: (e: ModuleError, boundaryName?: string) => ReactNode;
|
14
|
+
rethrow?: boolean;
|
15
|
+
rollbar?: Rollbar;
|
16
|
+
scope?: string;
|
17
|
+
title?: string;
|
18
|
+
}
|
19
|
+
interface ThrownErrorBoundaryState {
|
20
|
+
xyoError?: ModuleError;
|
21
|
+
}
|
22
|
+
declare class ThrownErrorBoundary extends Component<ThrownErrorBoundaryProps, ThrownErrorBoundaryState> {
|
23
|
+
state: ThrownErrorBoundaryState;
|
24
|
+
static getDerivedStateFromError(error: Error): ThrownErrorBoundaryState;
|
25
|
+
static normalizeError(error: Error | ModuleError): ModuleError;
|
26
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
27
|
+
render(): string | number | boolean | react_jsx_runtime.JSX.Element | Iterable<React.ReactNode> | null | undefined;
|
28
|
+
}
|
29
|
+
|
30
|
+
interface ErrorAlertProps extends AlertProps {
|
31
|
+
error?: ModuleError | Error | string;
|
32
|
+
errorContext?: string;
|
33
|
+
onCancel?: () => void;
|
34
|
+
scope?: string;
|
35
|
+
}
|
36
|
+
declare const ErrorAlert: React.FC<ErrorAlertProps>;
|
37
|
+
|
38
|
+
interface ErrorRenderProps extends FlexBoxProps {
|
39
|
+
customError?: ReactNode;
|
40
|
+
error?: ModuleError | Error;
|
41
|
+
errorContext?: string;
|
42
|
+
noErrorDisplay?: boolean;
|
43
|
+
noReAuth?: boolean;
|
44
|
+
onCancel?: () => void;
|
45
|
+
scope?: string;
|
46
|
+
useLocation?: () => Location;
|
47
|
+
}
|
48
|
+
|
49
|
+
declare const ErrorRender: React.FC<ErrorRenderProps>;
|
50
|
+
|
51
|
+
interface ErrorReporterProviderProps {
|
52
|
+
rollbar: Rollbar;
|
53
|
+
}
|
54
|
+
declare const ErrorReporterProvider: React.FC<WithChildren<ErrorReporterProviderProps>>;
|
55
|
+
|
56
|
+
interface ErrorReporterContextState {
|
57
|
+
rollbar?: Rollbar;
|
58
|
+
}
|
59
|
+
|
60
|
+
declare const useRollbar: () => ErrorReporterContextState;
|
61
|
+
|
62
|
+
export { ErrorAlert, type ErrorAlertProps, ErrorRender, type ErrorRenderProps, type ErrorReporterContextState, ErrorReporterProvider, type ErrorReporterProviderProps, ThrownErrorBoundary, type ThrownErrorBoundaryProps, type ThrownErrorBoundaryState, useRollbar };
|
@@ -0,0 +1,163 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
3
|
+
|
4
|
+
// src/components/ErrorBoundary/ThrownErrorBoundary.tsx
|
5
|
+
import { ModuleErrorSchema } from "@xyo-network/payload-model";
|
6
|
+
import React3, { Component } from "react";
|
7
|
+
|
8
|
+
// src/components/ErrorRender/ErrorAlert.tsx
|
9
|
+
import { ExitToApp as ExitIcon } from "@mui/icons-material";
|
10
|
+
import { Alert, AlertTitle, Typography } from "@mui/material";
|
11
|
+
import { ButtonEx } from "@xylabs/react-button";
|
12
|
+
import React from "react";
|
13
|
+
var ErrorAlert = /* @__PURE__ */ __name(({ title = "Whoops! Something went wrong", onCancel, error = "An unknown error occurred", errorContext, scope, ...props }) => {
|
14
|
+
const finalScope = scope ?? errorContext;
|
15
|
+
return /* @__PURE__ */ React.createElement(Alert, {
|
16
|
+
severity: "error",
|
17
|
+
...props
|
18
|
+
}, /* @__PURE__ */ React.createElement(AlertTitle, null, title), finalScope ? /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Typography, {
|
19
|
+
variant: "caption",
|
20
|
+
mr: 0.5,
|
21
|
+
fontWeight: "bold"
|
22
|
+
}, "Scope:"), /* @__PURE__ */ React.createElement(Typography, {
|
23
|
+
variant: "caption"
|
24
|
+
}, finalScope)) : null, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Typography, {
|
25
|
+
variant: "caption",
|
26
|
+
mr: 0.5,
|
27
|
+
fontWeight: "bold"
|
28
|
+
}, "Error:"), /* @__PURE__ */ React.createElement(Typography, {
|
29
|
+
variant: "caption"
|
30
|
+
}, typeof error === "string" ? error : error?.message)), onCancel ? /* @__PURE__ */ React.createElement(ButtonEx, {
|
31
|
+
variant: "outlined",
|
32
|
+
size: "small",
|
33
|
+
onClick: onCancel,
|
34
|
+
position: "absolute",
|
35
|
+
style: {
|
36
|
+
right: 8,
|
37
|
+
top: 8
|
38
|
+
}
|
39
|
+
}, /* @__PURE__ */ React.createElement(ExitIcon, {
|
40
|
+
fontSize: "small"
|
41
|
+
})) : null);
|
42
|
+
}, "ErrorAlert");
|
43
|
+
|
44
|
+
// src/components/ErrorRender/Render.tsx
|
45
|
+
import { FlexCol } from "@xylabs/react-flexbox";
|
46
|
+
import React2, { useEffect } from "react";
|
47
|
+
var ErrorRender = /* @__PURE__ */ __name(({ onCancel, error, noErrorDisplay = false, customError = null, children, errorContext, scope, useLocation, ...props }) => {
|
48
|
+
const location = useLocation?.();
|
49
|
+
useEffect(() => {
|
50
|
+
if (location) {
|
51
|
+
location.state = {
|
52
|
+
from: {
|
53
|
+
pathname: window.location.pathname
|
54
|
+
}
|
55
|
+
};
|
56
|
+
}
|
57
|
+
}, [
|
58
|
+
location
|
59
|
+
]);
|
60
|
+
return error ? /* @__PURE__ */ React2.createElement(FlexCol, {
|
61
|
+
alignItems: "stretch",
|
62
|
+
...props
|
63
|
+
}, noErrorDisplay ? customError : /* @__PURE__ */ React2.createElement(FlexCol, {
|
64
|
+
alignItems: "center",
|
65
|
+
...props
|
66
|
+
}, /* @__PURE__ */ React2.createElement(ErrorAlert, {
|
67
|
+
error,
|
68
|
+
errorContext,
|
69
|
+
onCancel,
|
70
|
+
scope
|
71
|
+
}))) : /* @__PURE__ */ React2.createElement(React2.Fragment, null, children) ?? null;
|
72
|
+
}, "ErrorRender");
|
73
|
+
|
74
|
+
// src/components/ErrorBoundary/ThrownErrorBoundary.tsx
|
75
|
+
var ThrownErrorBoundary = class _ThrownErrorBoundary extends Component {
|
76
|
+
static {
|
77
|
+
__name(this, "ThrownErrorBoundary");
|
78
|
+
}
|
79
|
+
state = {
|
80
|
+
xyoError: void 0
|
81
|
+
};
|
82
|
+
static getDerivedStateFromError(error) {
|
83
|
+
return {
|
84
|
+
hasError: true,
|
85
|
+
xyoError: _ThrownErrorBoundary.normalizeError(error)
|
86
|
+
};
|
87
|
+
}
|
88
|
+
static normalizeError(error) {
|
89
|
+
return error.schema === ModuleErrorSchema ? error : {
|
90
|
+
message: error.message,
|
91
|
+
schema: ModuleErrorSchema,
|
92
|
+
sources: []
|
93
|
+
};
|
94
|
+
}
|
95
|
+
componentDidCatch(error, errorInfo) {
|
96
|
+
const { rethrow, rollbar } = this.props;
|
97
|
+
const { xyoError } = this.state;
|
98
|
+
rollbar?.error(error);
|
99
|
+
console.error("Error:", xyoError, errorInfo);
|
100
|
+
if (rethrow) {
|
101
|
+
throw error;
|
102
|
+
}
|
103
|
+
}
|
104
|
+
render() {
|
105
|
+
const { xyoError } = this.state;
|
106
|
+
const { children, boundaryName, errorComponent, scope, title } = this.props;
|
107
|
+
if (xyoError) {
|
108
|
+
if (errorComponent) {
|
109
|
+
return errorComponent(xyoError);
|
110
|
+
}
|
111
|
+
return /* @__PURE__ */ React3.createElement(ErrorRender, {
|
112
|
+
error: xyoError,
|
113
|
+
errorContext: `${boundaryName} Boundary`,
|
114
|
+
scope,
|
115
|
+
title
|
116
|
+
});
|
117
|
+
}
|
118
|
+
return children;
|
119
|
+
}
|
120
|
+
};
|
121
|
+
|
122
|
+
// src/contexts/ErrorReporter/Provider.tsx
|
123
|
+
import React4, { useEffect as useEffect2, useState } from "react";
|
124
|
+
|
125
|
+
// src/contexts/ErrorReporter/Context.ts
|
126
|
+
import { createContext } from "react";
|
127
|
+
var ErrorReporterContext = createContext({});
|
128
|
+
|
129
|
+
// src/contexts/ErrorReporter/Provider.tsx
|
130
|
+
var ErrorReporterProvider = /* @__PURE__ */ __name(({ children, rollbar }) => {
|
131
|
+
const [rollbarInstance, setRollBarInstance] = useState();
|
132
|
+
useEffect2(() => {
|
133
|
+
if (rollbarInstance) {
|
134
|
+
setRollBarInstance(rollbarInstance);
|
135
|
+
}
|
136
|
+
}, [
|
137
|
+
rollbar,
|
138
|
+
rollbarInstance
|
139
|
+
]);
|
140
|
+
return /* @__PURE__ */ React4.createElement(ErrorReporterContext.Provider, {
|
141
|
+
value: {
|
142
|
+
rollbar
|
143
|
+
}
|
144
|
+
}, children);
|
145
|
+
}, "ErrorReporterProvider");
|
146
|
+
|
147
|
+
// src/contexts/ErrorReporter/useRollbar.tsx
|
148
|
+
import { useContext } from "react";
|
149
|
+
var useRollbar = /* @__PURE__ */ __name(() => {
|
150
|
+
const context = useContext(ErrorReporterContext);
|
151
|
+
if (context === void 0) {
|
152
|
+
console.warn("useRollbar must be used within a ErrorReporterContext");
|
153
|
+
}
|
154
|
+
return context ?? {};
|
155
|
+
}, "useRollbar");
|
156
|
+
export {
|
157
|
+
ErrorAlert,
|
158
|
+
ErrorRender,
|
159
|
+
ErrorReporterProvider,
|
160
|
+
ThrownErrorBoundary,
|
161
|
+
useRollbar
|
162
|
+
};
|
163
|
+
//# sourceMappingURL=index.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/components/ErrorBoundary/ThrownErrorBoundary.tsx","../../src/components/ErrorRender/ErrorAlert.tsx","../../src/components/ErrorRender/Render.tsx","../../src/contexts/ErrorReporter/Provider.tsx","../../src/contexts/ErrorReporter/Context.ts","../../src/contexts/ErrorReporter/useRollbar.tsx"],"sourcesContent":["import { ModuleError, ModuleErrorSchema } from '@xyo-network/payload-model'\nimport React, { Component, ErrorInfo, ReactNode } from 'react'\nimport Rollbar from 'rollbar'\n\nimport { ErrorRender } from '../ErrorRender/index.ts'\n\nexport interface ThrownErrorBoundaryProps {\n boundaryName?: string\n children: ReactNode\n errorComponent?: (e: ModuleError, boundaryName?: string) => ReactNode\n rethrow?: boolean\n rollbar?: Rollbar\n scope?: string\n title?: string\n}\n\nexport interface ThrownErrorBoundaryState {\n xyoError?: ModuleError\n}\n\nexport class ThrownErrorBoundary extends Component<ThrownErrorBoundaryProps, ThrownErrorBoundaryState> {\n override state: ThrownErrorBoundaryState = {\n xyoError: undefined,\n }\n\n static getDerivedStateFromError(error: Error) {\n return { hasError: true, xyoError: ThrownErrorBoundary.normalizeError(error) } as ThrownErrorBoundaryState\n }\n\n static normalizeError(error: Error | ModuleError): ModuleError {\n return (\n (error as ModuleError).schema === ModuleErrorSchema\n ? error\n : { message: error.message, schema: ModuleErrorSchema, sources: [] }) as ModuleError\n }\n\n override componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n const { rethrow, rollbar } = this.props\n const { xyoError } = this.state\n\n rollbar?.error(error)\n\n console.error('Error:', xyoError, errorInfo)\n if (rethrow) {\n throw error\n }\n }\n\n override render() {\n const { xyoError } = this.state\n const { children, boundaryName, errorComponent, scope, title } = this.props\n if (xyoError) {\n if (errorComponent) {\n return errorComponent(xyoError)\n }\n return <ErrorRender error={xyoError} errorContext={`${boundaryName} Boundary`} scope={scope} title={title} />\n }\n\n return children\n }\n}\n","import { ExitToApp as ExitIcon } from '@mui/icons-material'\nimport { Alert, AlertProps, AlertTitle, Typography } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleError } from '@xyo-network/payload-model'\nimport React from 'react'\n\nexport interface ErrorAlertProps extends AlertProps {\n error?: ModuleError | Error | string\n /** @deprecated use scope instead */\n errorContext?: string\n onCancel?: () => void\n scope?: string\n}\n\nexport const ErrorAlert: React.FC<ErrorAlertProps> = ({\n title = 'Whoops! Something went wrong',\n onCancel,\n error = 'An unknown error occurred',\n errorContext,\n scope,\n ...props\n}) => {\n const finalScope = scope ?? errorContext\n return (\n <Alert severity=\"error\" {...props}>\n <AlertTitle>{title}</AlertTitle>\n {finalScope\n ? (\n <div>\n <Typography variant=\"caption\" mr={0.5} fontWeight=\"bold\">\n Scope:\n </Typography>\n <Typography variant=\"caption\">{finalScope}</Typography>\n </div>\n )\n : null}\n <div>\n <Typography variant=\"caption\" mr={0.5} fontWeight=\"bold\">\n Error:\n </Typography>\n <Typography variant=\"caption\">{typeof error === 'string' ? error : error?.message}</Typography>\n </div>\n {onCancel\n ? (\n <ButtonEx variant=\"outlined\" size=\"small\" onClick={onCancel} position=\"absolute\" style={{ right: 8, top: 8 }}>\n <ExitIcon fontSize=\"small\" />\n </ButtonEx>\n )\n : null}\n </Alert>\n )\n}\n","import { FlexCol } from '@xylabs/react-flexbox'\nimport React, { useEffect } from 'react'\n\nimport { ErrorAlert } from './ErrorAlert.tsx'\nimport { ErrorRenderProps } from './Props.ts'\n\nexport const ErrorRender: React.FC<ErrorRenderProps> = ({\n onCancel,\n error,\n noErrorDisplay = false,\n customError = null,\n children,\n errorContext,\n scope,\n useLocation,\n ...props\n}) => {\n const location = useLocation?.()\n useEffect(() => {\n if (location) {\n // ensure we end up at the same place we are now after logging in\n location.state = {\n from: {\n pathname: window.location.pathname,\n },\n }\n }\n }, [location])\n\n return error\n ? (\n <FlexCol alignItems=\"stretch\" {...props}>\n {noErrorDisplay\n ? customError\n : (\n <FlexCol alignItems=\"center\" {...props}>\n <ErrorAlert error={error} errorContext={errorContext} onCancel={onCancel} scope={scope} />\n </FlexCol>\n )}\n </FlexCol>\n )\n : (<>{children}</> ?? null)\n}\n","import { WithChildren } from '@xylabs/react-shared'\nimport React, { useEffect, useState } from 'react'\nimport Rollbar from 'rollbar'\n\nimport { ErrorReporterContext } from './Context.ts'\n\nexport interface ErrorReporterProviderProps {\n rollbar: Rollbar\n}\n\nconst ErrorReporterProvider: React.FC<WithChildren<ErrorReporterProviderProps>> = ({ children, rollbar }) => {\n const [rollbarInstance, setRollBarInstance] = useState<Rollbar>()\n\n useEffect(() => {\n if (rollbarInstance) {\n setRollBarInstance(rollbarInstance)\n }\n }, [rollbar, rollbarInstance])\n\n // eslint-disable-next-line @eslint-react/no-unstable-context-value\n return <ErrorReporterContext.Provider value={{ rollbar }}>{children}</ErrorReporterContext.Provider>\n}\n\nexport { ErrorReporterProvider }\n","import { createContext } from 'react'\n\nimport { ErrorReporterContextState } from './State.ts'\n\nexport const ErrorReporterContext = createContext<ErrorReporterContextState>({})\n","import { useContext } from 'react'\n\nimport { ErrorReporterContext } from './Context.ts'\n\nconst useRollbar = () => {\n const context = useContext(ErrorReporterContext)\n if (context === undefined) {\n console.warn('useRollbar must be used within a ErrorReporterContext')\n }\n\n return context ?? {}\n}\n\nexport { useRollbar }\n"],"mappings":"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","names":["ModuleErrorSchema","React","Component","ExitToApp","ExitIcon","Alert","AlertTitle","Typography","ButtonEx","React","ErrorAlert","title","onCancel","error","errorContext","scope","props","finalScope","Alert","severity","AlertTitle","div","Typography","variant","mr","fontWeight","message","ButtonEx","size","onClick","position","style","right","top","ExitIcon","fontSize","FlexCol","React","useEffect","ErrorRender","onCancel","error","noErrorDisplay","customError","children","errorContext","scope","useLocation","props","location","useEffect","state","from","pathname","window","React","FlexCol","alignItems","ErrorAlert","ThrownErrorBoundary","Component","state","xyoError","undefined","getDerivedStateFromError","error","hasError","normalizeError","schema","ModuleErrorSchema","message","sources","componentDidCatch","errorInfo","rethrow","rollbar","props","console","render","children","boundaryName","errorComponent","scope","title","React","ErrorRender","errorContext","React","useEffect","useState","createContext","ErrorReporterContext","ErrorReporterProvider","children","rollbar","rollbarInstance","setRollBarInstance","useState","useEffect","React","ErrorReporterContext","Provider","value","useContext","useRollbar","context","useContext","ErrorReporterContext","undefined","console","warn"]}
|
package/package.json
CHANGED
@@ -10,11 +10,11 @@
|
|
10
10
|
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/issues"
|
11
11
|
},
|
12
12
|
"dependencies": {
|
13
|
-
"@xylabs/react-button": "^3.4.
|
14
|
-
"@xylabs/react-flexbox": "^3.4.
|
15
|
-
"@xylabs/react-shared": "^3.4.
|
16
|
-
"@xyo-network/payload-model": "^2.
|
17
|
-
"react-router-dom": "^6.
|
13
|
+
"@xylabs/react-button": "^3.4.2",
|
14
|
+
"@xylabs/react-flexbox": "^3.4.2",
|
15
|
+
"@xylabs/react-shared": "^3.4.2",
|
16
|
+
"@xyo-network/payload-model": "^2.111.3",
|
17
|
+
"react-router-dom": "^6.26.0"
|
18
18
|
},
|
19
19
|
"peerDependencies": {
|
20
20
|
"@mui/icons-material": "^5",
|
@@ -25,9 +25,9 @@
|
|
25
25
|
"rollbar": "^2"
|
26
26
|
},
|
27
27
|
"devDependencies": {
|
28
|
-
"@storybook/react": "^
|
29
|
-
"@xylabs/ts-scripts-yarn3": "^
|
30
|
-
"@xylabs/tsconfig-react": "^
|
28
|
+
"@storybook/react": "^8.2.7",
|
29
|
+
"@xylabs/ts-scripts-yarn3": "^4.0.0-rc.7",
|
30
|
+
"@xylabs/tsconfig-react": "^4.0.0-rc.7",
|
31
31
|
"typescript": "^5.5.4"
|
32
32
|
},
|
33
33
|
"peerDependenciesMeta": {
|
@@ -39,32 +39,16 @@
|
|
39
39
|
"docs": "dist/docs.json",
|
40
40
|
"exports": {
|
41
41
|
".": {
|
42
|
-
"
|
43
|
-
"
|
44
|
-
|
45
|
-
"default": "./dist/node/index.js"
|
46
|
-
},
|
47
|
-
"require": {
|
48
|
-
"types": "./dist/node/index.d.cts",
|
49
|
-
"default": "./dist/node/index.cjs"
|
50
|
-
}
|
42
|
+
"import": {
|
43
|
+
"types": "./dist/browser/index.d.ts",
|
44
|
+
"default": "./dist/browser/index.mjs"
|
51
45
|
},
|
52
|
-
"
|
53
|
-
|
54
|
-
"types": "./dist/browser/index.d.mts",
|
55
|
-
"default": "./dist/browser/index.js"
|
56
|
-
},
|
57
|
-
"require": {
|
58
|
-
"types": "./dist/browser/index.d.cts",
|
59
|
-
"default": "./dist/browser/index.cjs"
|
60
|
-
}
|
61
|
-
},
|
62
|
-
"default": "./dist/browser/index.js"
|
46
|
+
"types": "./dist/browser/index.d.ts",
|
47
|
+
"default": "./dist/browser/index.mjs"
|
63
48
|
},
|
64
49
|
"./package.json": "./package.json"
|
65
50
|
},
|
66
|
-
"
|
67
|
-
"module": "dist/browser/index.js",
|
51
|
+
"module": "dist/browser/index.mjs",
|
68
52
|
"homepage": "https://xyo.network",
|
69
53
|
"keywords": [
|
70
54
|
"xyo",
|
@@ -86,6 +70,6 @@
|
|
86
70
|
},
|
87
71
|
"sideEffects": false,
|
88
72
|
"types": "dist/browser/index.d.ts",
|
89
|
-
"version": "2.
|
73
|
+
"version": "2.83.0",
|
90
74
|
"type": "module"
|
91
75
|
}
|
@@ -1,8 +1,8 @@
|
|
1
|
-
/* eslint-disable import/no-internal-modules */
|
2
1
|
import { Alert } from '@mui/material'
|
3
2
|
import { Meta, StoryFn } from '@storybook/react'
|
3
|
+
import React from 'react'
|
4
4
|
|
5
|
-
import { ThrownErrorBoundary } from './ThrownErrorBoundary.
|
5
|
+
import { ThrownErrorBoundary } from './ThrownErrorBoundary.tsx'
|
6
6
|
|
7
7
|
const StorybookEntry: Meta = {
|
8
8
|
component: ThrownErrorBoundary,
|
@@ -22,10 +22,14 @@ Default.args = {}
|
|
22
22
|
|
23
23
|
const CustomErrorComponent = Template.bind({})
|
24
24
|
CustomErrorComponent.args = {
|
25
|
-
errorComponent:
|
25
|
+
errorComponent: e => (
|
26
|
+
<Alert severity="error">
|
27
|
+
Using Custom Error Component with error:
|
28
|
+
{e.message}
|
29
|
+
</Alert>
|
30
|
+
),
|
26
31
|
}
|
27
32
|
|
28
33
|
export { CustomErrorComponent, Default }
|
29
34
|
|
30
|
-
// eslint-disable-next-line import/no-default-export
|
31
35
|
export default StorybookEntry
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { ModuleError, ModuleErrorSchema } from '@xyo-network/payload-model'
|
2
|
-
import { Component, ErrorInfo, ReactNode } from 'react'
|
2
|
+
import React, { Component, ErrorInfo, ReactNode } from 'react'
|
3
3
|
import Rollbar from 'rollbar'
|
4
4
|
|
5
|
-
import { ErrorRender } from '../ErrorRender/index.
|
5
|
+
import { ErrorRender } from '../ErrorRender/index.ts'
|
6
6
|
|
7
7
|
export interface ThrownErrorBoundaryProps {
|
8
8
|
boundaryName?: string
|
@@ -29,9 +29,9 @@ export class ThrownErrorBoundary extends Component<ThrownErrorBoundaryProps, Thr
|
|
29
29
|
|
30
30
|
static normalizeError(error: Error | ModuleError): ModuleError {
|
31
31
|
return (
|
32
|
-
(error as ModuleError).schema === ModuleErrorSchema
|
33
|
-
error
|
34
|
-
|
32
|
+
(error as ModuleError).schema === ModuleErrorSchema
|
33
|
+
? error
|
34
|
+
: { message: error.message, schema: ModuleErrorSchema, sources: [] }) as ModuleError
|
35
35
|
}
|
36
36
|
|
37
37
|
override componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
@@ -1 +1 @@
|
|
1
|
-
export * from './ThrownErrorBoundary.
|
1
|
+
export * from './ThrownErrorBoundary.tsx'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Meta, StoryFn } from '@storybook/react'
|
2
2
|
import React from 'react'
|
3
3
|
|
4
|
-
import { ErrorAlert } from './ErrorAlert.
|
4
|
+
import { ErrorAlert } from './ErrorAlert.tsx'
|
5
5
|
|
6
6
|
const StorybookEntry: Meta = {
|
7
7
|
argTypes: {},
|
@@ -38,5 +38,4 @@ WithErrorAndScopeAndTitle.args = { error: 'An error happened', scope: 'Storybook
|
|
38
38
|
|
39
39
|
export { Default, WithError, WithErrorAndScope, WithErrorAndScopeAndTitle, WithScope, WithTitle }
|
40
40
|
|
41
|
-
// eslint-disable-next-line import/no-default-export
|
42
41
|
export default StorybookEntry
|
@@ -2,6 +2,7 @@ import { ExitToApp as ExitIcon } from '@mui/icons-material'
|
|
2
2
|
import { Alert, AlertProps, AlertTitle, Typography } from '@mui/material'
|
3
3
|
import { ButtonEx } from '@xylabs/react-button'
|
4
4
|
import { ModuleError } from '@xyo-network/payload-model'
|
5
|
+
import React from 'react'
|
5
6
|
|
6
7
|
export interface ErrorAlertProps extends AlertProps {
|
7
8
|
error?: ModuleError | Error | string
|
@@ -11,7 +12,6 @@ export interface ErrorAlertProps extends AlertProps {
|
|
11
12
|
scope?: string
|
12
13
|
}
|
13
14
|
|
14
|
-
// eslint-disable-next-line deprecation/deprecation
|
15
15
|
export const ErrorAlert: React.FC<ErrorAlertProps> = ({
|
16
16
|
title = 'Whoops! Something went wrong',
|
17
17
|
onCancel,
|
@@ -24,25 +24,29 @@ export const ErrorAlert: React.FC<ErrorAlertProps> = ({
|
|
24
24
|
return (
|
25
25
|
<Alert severity="error" {...props}>
|
26
26
|
<AlertTitle>{title}</AlertTitle>
|
27
|
-
{finalScope
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
27
|
+
{finalScope
|
28
|
+
? (
|
29
|
+
<div>
|
30
|
+
<Typography variant="caption" mr={0.5} fontWeight="bold">
|
31
|
+
Scope:
|
32
|
+
</Typography>
|
33
|
+
<Typography variant="caption">{finalScope}</Typography>
|
34
|
+
</div>
|
35
|
+
)
|
36
|
+
: null}
|
35
37
|
<div>
|
36
38
|
<Typography variant="caption" mr={0.5} fontWeight="bold">
|
37
39
|
Error:
|
38
40
|
</Typography>
|
39
41
|
<Typography variant="caption">{typeof error === 'string' ? error : error?.message}</Typography>
|
40
42
|
</div>
|
41
|
-
{onCancel
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
{onCancel
|
44
|
+
? (
|
45
|
+
<ButtonEx variant="outlined" size="small" onClick={onCancel} position="absolute" style={{ right: 8, top: 8 }}>
|
46
|
+
<ExitIcon fontSize="small" />
|
47
|
+
</ButtonEx>
|
48
|
+
)
|
49
|
+
: null}
|
46
50
|
</Alert>
|
47
51
|
)
|
48
52
|
}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { FlexCol } from '@xylabs/react-flexbox'
|
2
|
-
import { useEffect } from 'react'
|
2
|
+
import React, { useEffect } from 'react'
|
3
3
|
|
4
|
-
import { ErrorAlert } from './ErrorAlert.
|
5
|
-
import { ErrorRenderProps } from './Props.
|
4
|
+
import { ErrorAlert } from './ErrorAlert.tsx'
|
5
|
+
import { ErrorRenderProps } from './Props.ts'
|
6
6
|
|
7
7
|
export const ErrorRender: React.FC<ErrorRenderProps> = ({
|
8
8
|
onCancel,
|
@@ -27,14 +27,17 @@ export const ErrorRender: React.FC<ErrorRenderProps> = ({
|
|
27
27
|
}
|
28
28
|
}, [location])
|
29
29
|
|
30
|
-
return error
|
31
|
-
|
32
|
-
{
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
30
|
+
return error
|
31
|
+
? (
|
32
|
+
<FlexCol alignItems="stretch" {...props}>
|
33
|
+
{noErrorDisplay
|
34
|
+
? customError
|
35
|
+
: (
|
36
|
+
<FlexCol alignItems="center" {...props}>
|
37
|
+
<ErrorAlert error={error} errorContext={errorContext} onCancel={onCancel} scope={scope} />
|
38
|
+
</FlexCol>
|
39
|
+
)}
|
40
|
+
</FlexCol>
|
41
|
+
)
|
39
42
|
: (<>{children}</> ?? null)
|
40
43
|
}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
export * from './ErrorAlert.
|
2
|
-
export * from './Props.
|
3
|
-
export * from './Render.
|
1
|
+
export * from './ErrorAlert.tsx'
|
2
|
+
export * from './Props.ts'
|
3
|
+
export * from './Render.tsx'
|
package/src/components/index.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export * from './ErrorBoundary/index.
|
2
|
-
export * from './ErrorRender/index.
|
1
|
+
export * from './ErrorBoundary/index.ts'
|
2
|
+
export * from './ErrorRender/index.ts'
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import { Typography } from '@mui/material'
|
2
2
|
import { Meta, StoryFn } from '@storybook/react'
|
3
|
+
import React from 'react'
|
3
4
|
import Rollbar from 'rollbar'
|
4
5
|
|
5
|
-
import { ErrorReporterProvider } from './Provider.
|
6
|
-
import { useRollbar } from './useRollbar.
|
6
|
+
import { ErrorReporterProvider } from './Provider.tsx'
|
7
|
+
import { useRollbar } from './useRollbar.tsx'
|
7
8
|
|
8
9
|
const StorybookEntry = {
|
9
10
|
argTypes: {},
|
@@ -20,7 +21,14 @@ const RollbarComponent = () => {
|
|
20
21
|
const { rollbar } = useRollbar()
|
21
22
|
const rollbarFound = typeof rollbar?.error === 'function'
|
22
23
|
|
23
|
-
return
|
24
|
+
return (
|
25
|
+
<Typography color={rollbarFound ? 'green' : 'red'}>
|
26
|
+
Rollbar instance
|
27
|
+
{rollbarFound ? '' : 'NOT'}
|
28
|
+
{' '}
|
29
|
+
found from context!
|
30
|
+
</Typography>
|
31
|
+
)
|
24
32
|
}
|
25
33
|
|
26
34
|
const Template: StoryFn<typeof ErrorReporterProvider> = () => {
|
@@ -36,5 +44,4 @@ const Default = Template.bind({})
|
|
36
44
|
|
37
45
|
export { Default }
|
38
46
|
|
39
|
-
// eslint-disable-next-line import/no-default-export
|
40
47
|
export default StorybookEntry
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { WithChildren } from '@xylabs/react-shared'
|
2
|
-
import { useEffect, useState } from 'react'
|
2
|
+
import React, { useEffect, useState } from 'react'
|
3
3
|
import Rollbar from 'rollbar'
|
4
4
|
|
5
|
-
import { ErrorReporterContext } from './Context.
|
5
|
+
import { ErrorReporterContext } from './Context.ts'
|
6
6
|
|
7
7
|
export interface ErrorReporterProviderProps {
|
8
8
|
rollbar: Rollbar
|
@@ -17,6 +17,7 @@ const ErrorReporterProvider: React.FC<WithChildren<ErrorReporterProviderProps>>
|
|
17
17
|
}
|
18
18
|
}, [rollbar, rollbarInstance])
|
19
19
|
|
20
|
+
// eslint-disable-next-line @eslint-react/no-unstable-context-value
|
20
21
|
return <ErrorReporterContext.Provider value={{ rollbar }}>{children}</ErrorReporterContext.Provider>
|
21
22
|
}
|
22
23
|
|
@@ -1,3 +1,3 @@
|
|
1
|
-
export * from './Provider.
|
2
|
-
export * from './State.
|
3
|
-
export * from './useRollbar.
|
1
|
+
export * from './Provider.tsx'
|
2
|
+
export * from './State.ts'
|
3
|
+
export * from './useRollbar.tsx'
|
package/src/contexts/index.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export * from './ErrorReporter/index.
|
1
|
+
export * from './ErrorReporter/index.ts'
|
package/src/index.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export * from './components/index.
|
2
|
-
export * from './contexts/index.
|
1
|
+
export * from './components/index.ts'
|
2
|
+
export * from './contexts/index.ts'
|
package/xy.config.ts
ADDED
@@ -1,23 +0,0 @@
|
|
1
|
-
import { ModuleError } from '@xyo-network/payload-model';
|
2
|
-
import { Component, ErrorInfo, ReactNode } from 'react';
|
3
|
-
import Rollbar from 'rollbar';
|
4
|
-
export interface ThrownErrorBoundaryProps {
|
5
|
-
boundaryName?: string;
|
6
|
-
children: ReactNode;
|
7
|
-
errorComponent?: (e: ModuleError, boundaryName?: string) => ReactNode;
|
8
|
-
rethrow?: boolean;
|
9
|
-
rollbar?: Rollbar;
|
10
|
-
scope?: string;
|
11
|
-
title?: string;
|
12
|
-
}
|
13
|
-
export interface ThrownErrorBoundaryState {
|
14
|
-
xyoError?: ModuleError;
|
15
|
-
}
|
16
|
-
export declare class ThrownErrorBoundary extends Component<ThrownErrorBoundaryProps, ThrownErrorBoundaryState> {
|
17
|
-
state: ThrownErrorBoundaryState;
|
18
|
-
static getDerivedStateFromError(error: Error): ThrownErrorBoundaryState;
|
19
|
-
static normalizeError(error: Error | ModuleError): ModuleError;
|
20
|
-
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
21
|
-
render(): string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<ReactNode> | null | undefined;
|
22
|
-
}
|
23
|
-
//# sourceMappingURL=ThrownErrorBoundary.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"ThrownErrorBoundary.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorBoundary/ThrownErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAqB,MAAM,4BAA4B,CAAA;AAC3E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACvD,OAAO,OAAO,MAAM,SAAS,CAAA;AAI7B,MAAM,WAAW,wBAAwB;IACvC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,SAAS,CAAA;IACnB,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE,MAAM,KAAK,SAAS,CAAA;IACrE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,WAAW,CAAA;CACvB;AAED,qBAAa,mBAAoB,SAAQ,SAAS,CAAC,wBAAwB,EAAE,wBAAwB,CAAC;IAC3F,KAAK,EAAE,wBAAwB,CAEvC;IAED,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GACwC,wBAAwB;IAG5G,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,GAAG,WAAW;IAOrD,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS;IAYpD,MAAM;CAYhB"}
|