@xyo-network/react-error 3.0.2 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.ts +24 -0
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.ts.map +1 -0
- package/dist/browser/components/ErrorBoundary/index.d.ts +2 -0
- package/dist/browser/components/ErrorBoundary/index.d.ts.map +1 -0
- package/dist/browser/components/ErrorRender/ErrorAlert.d.ts +11 -0
- package/dist/browser/components/ErrorRender/ErrorAlert.d.ts.map +1 -0
- package/dist/browser/components/ErrorRender/Props.d.ts +15 -0
- package/dist/browser/components/ErrorRender/Props.d.ts.map +1 -0
- package/dist/browser/components/ErrorRender/Render.d.ts +4 -0
- package/dist/browser/components/ErrorRender/Render.d.ts.map +1 -0
- package/dist/browser/components/ErrorRender/index.d.ts +4 -0
- package/dist/browser/components/ErrorRender/index.d.ts.map +1 -0
- package/dist/browser/components/index.d.ts +3 -0
- package/dist/browser/components/index.d.ts.map +1 -0
- package/dist/browser/contexts/ErrorReporter/Context.d.ts +3 -0
- package/dist/browser/contexts/ErrorReporter/Context.d.ts.map +1 -0
- package/dist/browser/contexts/ErrorReporter/Provider.d.ts +9 -0
- package/dist/browser/contexts/ErrorReporter/Provider.d.ts.map +1 -0
- package/dist/browser/contexts/ErrorReporter/State.d.ts +5 -0
- package/dist/browser/contexts/ErrorReporter/State.d.ts.map +1 -0
- package/dist/browser/contexts/ErrorReporter/index.d.ts +4 -0
- package/dist/browser/contexts/ErrorReporter/index.d.ts.map +1 -0
- package/dist/browser/contexts/ErrorReporter/useRollbar.d.ts +3 -0
- package/dist/browser/contexts/ErrorReporter/useRollbar.d.ts.map +1 -0
- package/dist/browser/contexts/index.d.ts +2 -0
- package/dist/browser/contexts/index.d.ts.map +1 -0
- package/dist/browser/index.d.ts +3 -62
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +52 -45
- package/src/components/ErrorBoundary/ThrownErrorBoundary.tsx +7 -5
- package/src/components/ErrorRender/ErrorAlert.stories.tsx +7 -7
- package/src/components/ErrorRender/ErrorAlert.tsx +10 -2
- package/src/components/ErrorRender/Render.tsx +1 -5
- package/src/contexts/ErrorReporter/Provider.stories.tsx +1 -5
- package/xy.config.ts +1 -3
@@ -0,0 +1,24 @@
|
|
1
|
+
import type { ModuleError } from '@xyo-network/payload-model';
|
2
|
+
import type { ErrorInfo, ReactNode } from 'react';
|
3
|
+
import { Component } from 'react';
|
4
|
+
import type Rollbar from 'rollbar';
|
5
|
+
export interface ThrownErrorBoundaryProps {
|
6
|
+
boundaryName?: string;
|
7
|
+
children: ReactNode;
|
8
|
+
errorComponent?: (e: ModuleError, boundaryName?: string) => ReactNode;
|
9
|
+
rethrow?: boolean;
|
10
|
+
rollbar?: Rollbar;
|
11
|
+
scope?: string;
|
12
|
+
title?: string;
|
13
|
+
}
|
14
|
+
export interface ThrownErrorBoundaryState {
|
15
|
+
xyoError?: ModuleError;
|
16
|
+
}
|
17
|
+
export declare class ThrownErrorBoundary extends Component<ThrownErrorBoundaryProps, ThrownErrorBoundaryState> {
|
18
|
+
state: ThrownErrorBoundaryState;
|
19
|
+
static getDerivedStateFromError(error: Error): ThrownErrorBoundaryState;
|
20
|
+
static normalizeError(error: Error | ModuleError): ModuleError;
|
21
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
22
|
+
render(): string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<ReactNode> | null | undefined;
|
23
|
+
}
|
24
|
+
//# sourceMappingURL=ThrownErrorBoundary.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ThrownErrorBoundary.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorBoundary/ThrownErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAE7D,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjD,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAIlC,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,CAA0B;IAElE,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GACwC,wBAAwB;IAG5G,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,GAAG,WAAW;IASrD,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS;IAYpD,MAAM;CAchB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorBoundary/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import type { AlertProps } from '@mui/material';
|
2
|
+
import type { ModuleError } from '@xyo-network/payload-model';
|
3
|
+
import React from 'react';
|
4
|
+
export interface ErrorAlertProps extends AlertProps {
|
5
|
+
error?: ModuleError | Error | string;
|
6
|
+
errorContext?: string;
|
7
|
+
onCancel?: () => void;
|
8
|
+
scope?: string;
|
9
|
+
}
|
10
|
+
export declare const ErrorAlert: React.FC<ErrorAlertProps>;
|
11
|
+
//# sourceMappingURL=ErrorAlert.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ErrorAlert.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorRender/ErrorAlert.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAK/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,WAAW,eAAgB,SAAQ,UAAU;IACjD,KAAK,CAAC,EAAE,WAAW,GAAG,KAAK,GAAG,MAAM,CAAA;IAEpC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA2ChD,CAAA"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import type { FlexBoxProps } from '@xylabs/react-flexbox';
|
2
|
+
import type { ModuleError } from '@xyo-network/payload-model';
|
3
|
+
import type { ReactNode } from 'react';
|
4
|
+
import type { Location } from 'react-router-dom';
|
5
|
+
export interface ErrorRenderProps extends FlexBoxProps {
|
6
|
+
customError?: ReactNode;
|
7
|
+
error?: ModuleError | Error;
|
8
|
+
errorContext?: string;
|
9
|
+
noErrorDisplay?: boolean;
|
10
|
+
noReAuth?: boolean;
|
11
|
+
onCancel?: () => void;
|
12
|
+
scope?: string;
|
13
|
+
useLocation?: () => Location;
|
14
|
+
}
|
15
|
+
//# sourceMappingURL=Props.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Props.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorRender/Props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEhD,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IACpD,WAAW,CAAC,EAAE,SAAS,CAAA;IACvB,KAAK,CAAC,EAAE,WAAW,GAAG,KAAK,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,QAAQ,CAAA;CAC7B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Render.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorRender/Render.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoB,MAAM,OAAO,CAAA;AAGxC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAgClD,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/ErrorRender/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,wBAAwB,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../../src/contexts/ErrorReporter/Context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA;AAE3D,eAAO,MAAM,oBAAoB,oDAA+C,CAAA"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import type { WithChildren } from '@xylabs/react-shared';
|
2
|
+
import React from 'react';
|
3
|
+
import type Rollbar from 'rollbar';
|
4
|
+
export interface ErrorReporterProviderProps {
|
5
|
+
rollbar: Rollbar;
|
6
|
+
}
|
7
|
+
declare const ErrorReporterProvider: React.FC<WithChildren<ErrorReporterProviderProps>>;
|
8
|
+
export { ErrorReporterProvider };
|
9
|
+
//# sourceMappingURL=Provider.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../../src/contexts/ErrorReporter/Provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAA8B,MAAM,OAAO,CAAA;AAClD,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAIlC,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,QAAA,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,0BAA0B,CAAC,CAW7E,CAAA;AAED,OAAO,EAAE,qBAAqB,EAAE,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"State.d.ts","sourceRoot":"","sources":["../../../../src/contexts/ErrorReporter/State.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAElC,MAAM,WAAW,yBAAyB;IACxC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/contexts/ErrorReporter/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useRollbar.d.ts","sourceRoot":"","sources":["../../../../src/contexts/ErrorReporter/useRollbar.tsx"],"names":[],"mappings":"AAIA,QAAA,MAAM,UAAU,sDAOf,CAAA;AAED,OAAO,EAAE,UAAU,EAAE,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/contexts/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA"}
|
package/dist/browser/index.d.ts
CHANGED
@@ -1,62 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
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<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 };
|
1
|
+
export * from './components/index.ts';
|
2
|
+
export * from './contexts/index.ts';
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA"}
|
@@ -1 +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 type { ModuleError } from '@xyo-network/payload-model'\nimport { ModuleErrorSchema } from '@xyo-network/payload-model'\nimport type { ErrorInfo, ReactNode } from 'react'\nimport React, { Component } from 'react'\nimport type 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 type { AlertProps } from '@mui/material'\nimport { Alert, AlertTitle, Typography } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport type { 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 type { 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 type { WithChildren } from '@xylabs/react-shared'\nimport React, { useEffect, useState } from 'react'\nimport type 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 type { 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":";;;;AACA,SAASA,yBAAyB;AAElC,OAAOC,UAASC,iBAAiB;;;ACHjC,SAASC,aAAaC,gBAAgB;AAEtC,SAASC,OAAOC,YAAYC,kBAAkB;AAC9C,SAASC,gBAAgB;AAEzB,OAAOC,WAAW;AAUX,IAAMC,aAAwC,wBAAC,EACpDC,QAAQ,gCACRC,UACAC,QAAQ,6BACRC,cACAC,OACA,GAAGC,MAAAA,MACJ;AACC,QAAMC,aAAaF,SAASD;AAC5B,SACE,sBAAA,cAACI,OAAAA;IAAMC,UAAS;IAAS,GAAGH;KAC1B,sBAAA,cAACI,YAAAA,MAAYT,KAAAA,GACZM,aAEK,sBAAA,cAACI,OAAAA,MACC,sBAAA,cAACC,YAAAA;IAAWC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Q;KAAID,QAAAA;AAC7D,GAXkF;;;AEVlF,SAASU,kBAAkB;AAI3B,IAAMC,aAAa,6BAAA;AACjB,QAAMC,UAAUC,WAAWC,oBAAAA;AAC3B,MAAIF,YAAYG,QAAW;AACzBC,YAAQC,KAAK,uDAAA;EACf;AAEA,SAAOL,WAAW,CAAC;AACrB,GAPmB;","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"]}
|
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 type { ModuleError } from '@xyo-network/payload-model'\nimport { ModuleErrorSchema } from '@xyo-network/payload-model'\nimport type { ErrorInfo, ReactNode } from 'react'\nimport React, { Component } from 'react'\nimport type 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 = { xyoError: undefined }\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 : {\n message: error.message, schema: ModuleErrorSchema, sources: [],\n }) 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 {\n children, boundaryName, errorComponent, scope, title,\n } = 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 type { AlertProps } from '@mui/material'\nimport {\n Alert, AlertTitle, Typography,\n} from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport type { 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\n variant=\"outlined\"\n size=\"small\"\n onClick={onCancel}\n position=\"absolute\"\n style={{ right: 8, top: 8 }}\n >\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 type { 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 = { from: { pathname: window.location.pathname } }\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 type { WithChildren } from '@xylabs/react-shared'\nimport React, { useEffect, useState } from 'react'\nimport type 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 type { 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":";;;;AACA,SAASA,yBAAyB;AAElC,OAAOC,UAASC,iBAAiB;;;ACHjC,SAASC,aAAaC,gBAAgB;AAEtC,SACEC,OAAOC,YAAYC,kBACd;AACP,SAASC,gBAAgB;AAEzB,OAAOC,WAAW;AAUX,IAAMC,aAAwC,wBAAC,EACpDC,QAAQ,gCACRC,UACAC,QAAQ,6BACRC,cACAC,OACA,GAAGC,MAAAA,MACJ;AACC,QAAMC,aAAaF,SAASD;AAC5B,SACE,sBAAA,cAACI,OAAAA;IAAMC,UAAS;IAAS,GAAGH;KAC1B,sBAAA,cAACI,YAAAA,MAAYT,KAAAA,GACZM,aAEK,sBAAA,cAACI,OAAAA,MACC,sBAAA,cAACC,YAAAA;IAAWC,SAAQ;IAAUC,IAAI;IAAKC,YAAW;KAAO,QAAA,GAGzD,sBAAA,cAACH,YAAAA;IAAWC,SAAQ;KAAWN,UAAAA,CAAAA,IAGnC,MACJ,sBAAA,cAACI,OAAAA,MACC,sBAAA,cAACC,YAAAA;IAAWC,SAAQ;IAAUC,IAAI;IAAKC,YAAW;KAAO,QAAA,GAGzD,sBAAA,cAACH,YAAAA;IAAWC,SAAQ;KAAW,OAAOV,UAAU,WAAWA,QAAQA,OAAOa,OAAAA,CAAAA,GAE3Ed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AAO,IAAK,KAAKC;AAClC,UAAM,EAAEd,SAAQ,IAAK,KAAKD;AAE1Bc,aAASV,MAAMA,KAAAA;AAEfY,YAAQZ,MAAM,UAAUH,UAAUW,SAAAA;AAClC,QAAIC,SAAS;AACX,YAAMT;IACR;EACF;EAESa,SAAS;AAChB,UAAM,EAAEhB,SAAQ,IAAK,KAAKD;AAC1B,UAAM,EACJkB,UAAUC,cAAcC,gBAAgBC,OAAOC,MAAK,IAClD,KAAKP;AACT,QAAId,UAAU;AACZ,UAAImB,gBAAgB;AAClB,eAAOA,eAAenB,QAAAA;MACxB;AACA,aAAO,gBAAAsB,OAAA,cAACC,aAAAA;QAAYpB,OAAOH;QAAUwB,cAAc,GAAGN,YAAAA;QAAyBE;QAAcC;;IAC/F;AAEA,WAAOJ;EACT;AACF;;;AG/DA,OAAOQ,UAASC,aAAAA,YAAWC,gBAAgB;;;ACD3C,SAASC,qBAAqB;AAIvB,IAAMC,uBAAuBD,cAAyC,CAAC,CAAA;;;ADM9E,IAAME,wBAA4E,wBAAC,EAAEC,UAAUC,QAAO,MAAE;AACtG,QAAM,CAACC,iBAAiBC,kBAAAA,IAAsBC,SAAAA;AAE9CC,EAAAA,WAAU,MAAA;AACR,QAAIH,iBAAiB;AACnBC,yBAAmBD,eAAAA;IACrB;EACF,GAAG;IAACD;IAASC;GAAgB;AAG7B,SAAO,gBAAAI,OAAA,cAACC,qBAAqBC,UAAQ;IAACC,OAAO;MAAER;IAAQ;KAAID,QAAAA;AAC7D,GAXkF;;;AEVlF,SAASU,kBAAkB;AAI3B,IAAMC,aAAa,6BAAA;AACjB,QAAMC,UAAUC,WAAWC,oBAAAA;AAC3B,MAAIF,YAAYG,QAAW;AACzBC,YAAQC,KAAK,uDAAA;EACf;AAEA,SAAOL,WAAW,CAAC;AACrB,GAPmB;","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
@@ -1,21 +1,67 @@
|
|
1
1
|
{
|
2
2
|
"name": "@xyo-network/react-error",
|
3
|
+
"version": "3.0.4",
|
4
|
+
"description": "Common React library for all XYO projects that use React",
|
5
|
+
"keywords": [
|
6
|
+
"xyo",
|
7
|
+
"utility",
|
8
|
+
"typescript",
|
9
|
+
"react"
|
10
|
+
],
|
11
|
+
"homepage": "https://xyo.network",
|
12
|
+
"bugs": {
|
13
|
+
"url": "git+https://github.com/XYOracleNetwork/sdk-xyo-react-js/issues",
|
14
|
+
"email": "support@xyo.network"
|
15
|
+
},
|
16
|
+
"repository": {
|
17
|
+
"type": "git",
|
18
|
+
"url": "git+https://github.com/XYOracleNetwork/sdk-xyo-react-js.git"
|
19
|
+
},
|
20
|
+
"license": "LGPL-3.0-only",
|
3
21
|
"author": {
|
4
|
-
"email": "support@xyo.network",
|
5
22
|
"name": "XYO Development Team",
|
23
|
+
"email": "support@xyo.network",
|
6
24
|
"url": "https://xyo.network"
|
7
25
|
},
|
8
|
-
"
|
9
|
-
|
10
|
-
|
26
|
+
"sideEffects": false,
|
27
|
+
"type": "module",
|
28
|
+
"exports": {
|
29
|
+
".": {
|
30
|
+
"import": {
|
31
|
+
"types": "./dist/browser/index.d.ts",
|
32
|
+
"default": "./dist/browser/index.mjs"
|
33
|
+
},
|
34
|
+
"types": "./dist/browser/index.d.ts",
|
35
|
+
"default": "./dist/browser/index.mjs"
|
36
|
+
},
|
37
|
+
"./package.json": "./package.json"
|
38
|
+
},
|
39
|
+
"module": "dist/browser/index.mjs",
|
40
|
+
"types": "dist/browser/index.d.ts",
|
41
|
+
"scripts": {
|
42
|
+
"license": "yarn license-checker --exclude \"MIT, ISC, Apache-2.0, BSD, BSD-2-Clause, CC-BY-4.0, Unlicense, CC-BY-3.0, CC0-1.0\"",
|
43
|
+
"lint-pkg": "npmPkgJsonLint ."
|
11
44
|
},
|
12
45
|
"dependencies": {
|
13
46
|
"@xylabs/react-button": "^4.0.3",
|
14
47
|
"@xylabs/react-flexbox": "^4.0.3",
|
15
48
|
"@xylabs/react-shared": "^4.0.3",
|
16
|
-
"@xyo-network/payload-model": "^3.0.
|
49
|
+
"@xyo-network/payload-model": "^3.0.15",
|
17
50
|
"react-router-dom": "^6.26.1"
|
18
51
|
},
|
52
|
+
"devDependencies": {
|
53
|
+
"@mui/icons-material": "^5.16.7",
|
54
|
+
"@mui/material": "^5.16.7",
|
55
|
+
"@mui/styles": "^5.16.7",
|
56
|
+
"@storybook/react": "^8.2.9",
|
57
|
+
"@xylabs/ts-scripts-yarn3": "^4.0.7",
|
58
|
+
"@xylabs/tsconfig-react": "^4.0.7",
|
59
|
+
"react": "^18.3.1",
|
60
|
+
"react-dom": "^18.3.1",
|
61
|
+
"rollbar": "^2.26.4",
|
62
|
+
"storybook": "^8.2.9",
|
63
|
+
"typescript": "^5.5.4"
|
64
|
+
},
|
19
65
|
"peerDependencies": {
|
20
66
|
"@mui/icons-material": "^5",
|
21
67
|
"@mui/material": "^5",
|
@@ -24,52 +70,13 @@
|
|
24
70
|
"react-dom": "^18",
|
25
71
|
"rollbar": "^2"
|
26
72
|
},
|
27
|
-
"devDependencies": {
|
28
|
-
"@storybook/react": "^8.2.9",
|
29
|
-
"@xylabs/ts-scripts-yarn3": "^4.0.0-rc.20",
|
30
|
-
"@xylabs/tsconfig-react": "^4.0.0-rc.20",
|
31
|
-
"typescript": "^5.5.4"
|
32
|
-
},
|
33
73
|
"peerDependenciesMeta": {
|
34
74
|
"rollbar": {
|
35
75
|
"optional": true
|
36
76
|
}
|
37
77
|
},
|
38
|
-
"description": "Common React library for all XYO projects that use React",
|
39
|
-
"docs": "dist/docs.json",
|
40
|
-
"exports": {
|
41
|
-
".": {
|
42
|
-
"import": {
|
43
|
-
"types": "./dist/browser/index.d.ts",
|
44
|
-
"default": "./dist/browser/index.mjs"
|
45
|
-
},
|
46
|
-
"types": "./dist/browser/index.d.ts",
|
47
|
-
"default": "./dist/browser/index.mjs"
|
48
|
-
},
|
49
|
-
"./package.json": "./package.json"
|
50
|
-
},
|
51
|
-
"module": "dist/browser/index.mjs",
|
52
|
-
"homepage": "https://xyo.network",
|
53
|
-
"keywords": [
|
54
|
-
"xyo",
|
55
|
-
"utility",
|
56
|
-
"typescript",
|
57
|
-
"react"
|
58
|
-
],
|
59
|
-
"license": "LGPL-3.0-only",
|
60
78
|
"publishConfig": {
|
61
79
|
"access": "public"
|
62
80
|
},
|
63
|
-
"
|
64
|
-
"type": "git",
|
65
|
-
"url": "git+https://github.com/XYOracleNetwork/sdk-xyo-react-js.git"
|
66
|
-
},
|
67
|
-
"scripts": {
|
68
|
-
"lint-pkg": "npmPkgJsonLint .",
|
69
|
-
"license": "yarn license-checker --exclude \"MIT, ISC, Apache-2.0, BSD, BSD-2-Clause, CC-BY-4.0, Unlicense, CC-BY-3.0, CC0-1.0\""
|
70
|
-
},
|
71
|
-
"sideEffects": false,
|
72
|
-
"types": "dist/browser/index.d.ts",
|
73
|
-
"version": "3.0.2",
|
74
|
-
"type": "module"
|
81
|
+
"docs": "dist/docs.json"
|
75
82
|
}
|
@@ -21,9 +21,7 @@ export interface ThrownErrorBoundaryState {
|
|
21
21
|
}
|
22
22
|
|
23
23
|
export class ThrownErrorBoundary extends Component<ThrownErrorBoundaryProps, ThrownErrorBoundaryState> {
|
24
|
-
override state: ThrownErrorBoundaryState = {
|
25
|
-
xyoError: undefined,
|
26
|
-
}
|
24
|
+
override state: ThrownErrorBoundaryState = { xyoError: undefined }
|
27
25
|
|
28
26
|
static getDerivedStateFromError(error: Error) {
|
29
27
|
return { hasError: true, xyoError: ThrownErrorBoundary.normalizeError(error) } as ThrownErrorBoundaryState
|
@@ -33,7 +31,9 @@ export class ThrownErrorBoundary extends Component<ThrownErrorBoundaryProps, Thr
|
|
33
31
|
return (
|
34
32
|
(error as ModuleError).schema === ModuleErrorSchema
|
35
33
|
? error
|
36
|
-
: {
|
34
|
+
: {
|
35
|
+
message: error.message, schema: ModuleErrorSchema, sources: [],
|
36
|
+
}) as ModuleError
|
37
37
|
}
|
38
38
|
|
39
39
|
override componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
@@ -50,7 +50,9 @@ export class ThrownErrorBoundary extends Component<ThrownErrorBoundaryProps, Thr
|
|
50
50
|
|
51
51
|
override render() {
|
52
52
|
const { xyoError } = this.state
|
53
|
-
const {
|
53
|
+
const {
|
54
|
+
children, boundaryName, errorComponent, scope, title,
|
55
|
+
} = this.props
|
54
56
|
if (xyoError) {
|
55
57
|
if (errorComponent) {
|
56
58
|
return errorComponent(xyoError)
|
@@ -6,11 +6,7 @@ import { ErrorAlert } from './ErrorAlert.tsx'
|
|
6
6
|
const StorybookEntry: Meta = {
|
7
7
|
argTypes: {},
|
8
8
|
component: ErrorAlert,
|
9
|
-
parameters: {
|
10
|
-
docs: {
|
11
|
-
page: null,
|
12
|
-
},
|
13
|
-
},
|
9
|
+
parameters: { docs: { page: null } },
|
14
10
|
title: 'error/ErrorAlert',
|
15
11
|
}
|
16
12
|
|
@@ -34,8 +30,12 @@ const WithErrorAndScope = Template.bind({})
|
|
34
30
|
WithErrorAndScope.args = { error: 'An error happened', scope: 'Storybook' }
|
35
31
|
|
36
32
|
const WithErrorAndScopeAndTitle = Template.bind({})
|
37
|
-
WithErrorAndScopeAndTitle.args = {
|
33
|
+
WithErrorAndScopeAndTitle.args = {
|
34
|
+
error: 'An error happened', scope: 'Storybook', title: 'Oh No!',
|
35
|
+
}
|
38
36
|
|
39
|
-
export {
|
37
|
+
export {
|
38
|
+
Default, WithError, WithErrorAndScope, WithErrorAndScopeAndTitle, WithScope, WithTitle,
|
39
|
+
}
|
40
40
|
|
41
41
|
export default StorybookEntry
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { ExitToApp as ExitIcon } from '@mui/icons-material'
|
2
2
|
import type { AlertProps } from '@mui/material'
|
3
|
-
import {
|
3
|
+
import {
|
4
|
+
Alert, AlertTitle, Typography,
|
5
|
+
} from '@mui/material'
|
4
6
|
import { ButtonEx } from '@xylabs/react-button'
|
5
7
|
import type { ModuleError } from '@xyo-network/payload-model'
|
6
8
|
import React from 'react'
|
@@ -43,7 +45,13 @@ export const ErrorAlert: React.FC<ErrorAlertProps> = ({
|
|
43
45
|
</div>
|
44
46
|
{onCancel
|
45
47
|
? (
|
46
|
-
<ButtonEx
|
48
|
+
<ButtonEx
|
49
|
+
variant="outlined"
|
50
|
+
size="small"
|
51
|
+
onClick={onCancel}
|
52
|
+
position="absolute"
|
53
|
+
style={{ right: 8, top: 8 }}
|
54
|
+
>
|
47
55
|
<ExitIcon fontSize="small" />
|
48
56
|
</ButtonEx>
|
49
57
|
)
|
@@ -19,11 +19,7 @@ export const ErrorRender: React.FC<ErrorRenderProps> = ({
|
|
19
19
|
useEffect(() => {
|
20
20
|
if (location) {
|
21
21
|
// ensure we end up at the same place we are now after logging in
|
22
|
-
location.state = {
|
23
|
-
from: {
|
24
|
-
pathname: window.location.pathname,
|
25
|
-
},
|
26
|
-
}
|
22
|
+
location.state = { from: { pathname: window.location.pathname } }
|
27
23
|
}
|
28
24
|
}, [location])
|
29
25
|
|
@@ -9,11 +9,7 @@ import { useRollbar } from './useRollbar.tsx'
|
|
9
9
|
const StorybookEntry = {
|
10
10
|
argTypes: {},
|
11
11
|
component: ErrorReporterProvider,
|
12
|
-
parameters: {
|
13
|
-
docs: {
|
14
|
-
page: null,
|
15
|
-
},
|
16
|
-
},
|
12
|
+
parameters: { docs: { page: null } },
|
17
13
|
title: 'auth-service/ErrorReporterProvider',
|
18
14
|
} as Meta<typeof ErrorReporterProvider>
|
19
15
|
|