@xyo-network/react-error 2.81.9 → 2.82.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.cts +3 -2
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.cts.map +1 -1
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.mts +3 -2
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.mts.map +1 -1
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.ts +3 -2
- package/dist/browser/components/ErrorBoundary/ThrownErrorBoundary.d.ts.map +1 -1
- package/dist/browser/components/ErrorBoundary/index.d.cts +1 -1
- package/dist/browser/components/ErrorBoundary/index.d.cts.map +1 -1
- package/dist/browser/components/ErrorBoundary/index.d.mts +1 -1
- package/dist/browser/components/ErrorBoundary/index.d.mts.map +1 -1
- package/dist/browser/components/ErrorBoundary/index.d.ts +1 -1
- package/dist/browser/components/ErrorBoundary/index.d.ts.map +1 -1
- package/dist/browser/components/ErrorRender/ErrorAlert.d.cts +2 -1
- package/dist/browser/components/ErrorRender/ErrorAlert.d.cts.map +1 -1
- package/dist/browser/components/ErrorRender/ErrorAlert.d.mts +2 -1
- package/dist/browser/components/ErrorRender/ErrorAlert.d.mts.map +1 -1
- package/dist/browser/components/ErrorRender/ErrorAlert.d.ts +2 -1
- package/dist/browser/components/ErrorRender/ErrorAlert.d.ts.map +1 -1
- package/dist/browser/components/ErrorRender/Render.d.cts +2 -1
- package/dist/browser/components/ErrorRender/Render.d.cts.map +1 -1
- package/dist/browser/components/ErrorRender/Render.d.mts +2 -1
- package/dist/browser/components/ErrorRender/Render.d.mts.map +1 -1
- package/dist/browser/components/ErrorRender/Render.d.ts +2 -1
- package/dist/browser/components/ErrorRender/Render.d.ts.map +1 -1
- package/dist/browser/components/ErrorRender/index.d.cts +3 -3
- package/dist/browser/components/ErrorRender/index.d.cts.map +1 -1
- package/dist/browser/components/ErrorRender/index.d.mts +3 -3
- package/dist/browser/components/ErrorRender/index.d.mts.map +1 -1
- package/dist/browser/components/ErrorRender/index.d.ts +3 -3
- package/dist/browser/components/ErrorRender/index.d.ts.map +1 -1
- package/dist/browser/components/index.d.cts +2 -2
- package/dist/browser/components/index.d.mts +2 -2
- package/dist/browser/components/index.d.ts +2 -2
- package/dist/browser/contexts/ErrorReporter/Context.d.cts +1 -1
- package/dist/browser/contexts/ErrorReporter/Context.d.mts +1 -1
- package/dist/browser/contexts/ErrorReporter/Context.d.ts +1 -1
- package/dist/browser/contexts/ErrorReporter/Provider.d.cts +1 -0
- package/dist/browser/contexts/ErrorReporter/Provider.d.cts.map +1 -1
- package/dist/browser/contexts/ErrorReporter/Provider.d.mts +1 -0
- package/dist/browser/contexts/ErrorReporter/Provider.d.mts.map +1 -1
- package/dist/browser/contexts/ErrorReporter/Provider.d.ts +1 -0
- package/dist/browser/contexts/ErrorReporter/Provider.d.ts.map +1 -1
- package/dist/browser/contexts/ErrorReporter/index.d.cts +3 -3
- package/dist/browser/contexts/ErrorReporter/index.d.cts.map +1 -1
- package/dist/browser/contexts/ErrorReporter/index.d.mts +3 -3
- package/dist/browser/contexts/ErrorReporter/index.d.mts.map +1 -1
- package/dist/browser/contexts/ErrorReporter/index.d.ts +3 -3
- package/dist/browser/contexts/ErrorReporter/index.d.ts.map +1 -1
- package/dist/browser/contexts/ErrorReporter/useRollbar.d.cts +1 -1
- package/dist/browser/contexts/ErrorReporter/useRollbar.d.mts +1 -1
- package/dist/browser/contexts/ErrorReporter/useRollbar.d.ts +1 -1
- package/dist/browser/contexts/index.d.cts +1 -1
- package/dist/browser/contexts/index.d.mts +1 -1
- package/dist/browser/contexts/index.d.ts +1 -1
- package/dist/browser/index.cjs +102 -52
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +2 -2
- package/dist/browser/index.d.mts +2 -2
- package/dist/browser/index.d.ts +2 -2
- package/dist/browser/index.mjs +163 -0
- package/dist/browser/index.mjs.map +1 -0
- package/dist/neutral/components/ErrorBoundary/ThrownErrorBoundary.d.cts +3 -2
- package/dist/neutral/components/ErrorBoundary/ThrownErrorBoundary.d.cts.map +1 -1
- package/dist/neutral/components/ErrorBoundary/ThrownErrorBoundary.d.mts +3 -2
- package/dist/neutral/components/ErrorBoundary/ThrownErrorBoundary.d.mts.map +1 -1
- package/dist/neutral/components/ErrorBoundary/ThrownErrorBoundary.d.ts +3 -2
- package/dist/neutral/components/ErrorBoundary/ThrownErrorBoundary.d.ts.map +1 -1
- package/dist/neutral/components/ErrorBoundary/index.d.cts +1 -1
- package/dist/neutral/components/ErrorBoundary/index.d.cts.map +1 -1
- package/dist/neutral/components/ErrorBoundary/index.d.mts +1 -1
- package/dist/neutral/components/ErrorBoundary/index.d.mts.map +1 -1
- package/dist/neutral/components/ErrorBoundary/index.d.ts +1 -1
- package/dist/neutral/components/ErrorBoundary/index.d.ts.map +1 -1
- package/dist/neutral/components/ErrorRender/ErrorAlert.d.cts +2 -1
- package/dist/neutral/components/ErrorRender/ErrorAlert.d.cts.map +1 -1
- package/dist/neutral/components/ErrorRender/ErrorAlert.d.mts +2 -1
- package/dist/neutral/components/ErrorRender/ErrorAlert.d.mts.map +1 -1
- package/dist/neutral/components/ErrorRender/ErrorAlert.d.ts +2 -1
- package/dist/neutral/components/ErrorRender/ErrorAlert.d.ts.map +1 -1
- package/dist/neutral/components/ErrorRender/Render.d.cts +2 -1
- package/dist/neutral/components/ErrorRender/Render.d.cts.map +1 -1
- package/dist/neutral/components/ErrorRender/Render.d.mts +2 -1
- package/dist/neutral/components/ErrorRender/Render.d.mts.map +1 -1
- package/dist/neutral/components/ErrorRender/Render.d.ts +2 -1
- package/dist/neutral/components/ErrorRender/Render.d.ts.map +1 -1
- package/dist/neutral/components/ErrorRender/index.d.cts +3 -3
- package/dist/neutral/components/ErrorRender/index.d.cts.map +1 -1
- package/dist/neutral/components/ErrorRender/index.d.mts +3 -3
- package/dist/neutral/components/ErrorRender/index.d.mts.map +1 -1
- package/dist/neutral/components/ErrorRender/index.d.ts +3 -3
- package/dist/neutral/components/ErrorRender/index.d.ts.map +1 -1
- package/dist/neutral/components/index.d.cts +2 -2
- package/dist/neutral/components/index.d.mts +2 -2
- package/dist/neutral/components/index.d.ts +2 -2
- package/dist/neutral/contexts/ErrorReporter/Context.d.cts +1 -1
- package/dist/neutral/contexts/ErrorReporter/Context.d.mts +1 -1
- package/dist/neutral/contexts/ErrorReporter/Context.d.ts +1 -1
- package/dist/neutral/contexts/ErrorReporter/Provider.d.cts +1 -0
- package/dist/neutral/contexts/ErrorReporter/Provider.d.cts.map +1 -1
- package/dist/neutral/contexts/ErrorReporter/Provider.d.mts +1 -0
- package/dist/neutral/contexts/ErrorReporter/Provider.d.mts.map +1 -1
- package/dist/neutral/contexts/ErrorReporter/Provider.d.ts +1 -0
- package/dist/neutral/contexts/ErrorReporter/Provider.d.ts.map +1 -1
- package/dist/neutral/contexts/ErrorReporter/index.d.cts +3 -3
- package/dist/neutral/contexts/ErrorReporter/index.d.cts.map +1 -1
- package/dist/neutral/contexts/ErrorReporter/index.d.mts +3 -3
- package/dist/neutral/contexts/ErrorReporter/index.d.mts.map +1 -1
- package/dist/neutral/contexts/ErrorReporter/index.d.ts +3 -3
- package/dist/neutral/contexts/ErrorReporter/index.d.ts.map +1 -1
- package/dist/neutral/contexts/ErrorReporter/useRollbar.d.cts +1 -1
- package/dist/neutral/contexts/ErrorReporter/useRollbar.d.mts +1 -1
- package/dist/neutral/contexts/ErrorReporter/useRollbar.d.ts +1 -1
- package/dist/neutral/contexts/index.d.cts +1 -1
- package/dist/neutral/contexts/index.d.mts +1 -1
- package/dist/neutral/contexts/index.d.ts +1 -1
- package/dist/neutral/index.cjs +102 -52
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.d.cts +2 -2
- package/dist/neutral/index.d.mts +2 -2
- package/dist/neutral/index.d.ts +2 -2
- package/dist/neutral/index.mjs +163 -0
- package/dist/neutral/index.mjs.map +1 -0
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.cts +3 -2
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.cts.map +1 -1
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.mts +3 -2
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.mts.map +1 -1
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.ts +3 -2
- package/dist/node/components/ErrorBoundary/ThrownErrorBoundary.d.ts.map +1 -1
- package/dist/node/components/ErrorBoundary/index.d.cts +1 -1
- package/dist/node/components/ErrorBoundary/index.d.cts.map +1 -1
- package/dist/node/components/ErrorBoundary/index.d.mts +1 -1
- package/dist/node/components/ErrorBoundary/index.d.mts.map +1 -1
- package/dist/node/components/ErrorBoundary/index.d.ts +1 -1
- package/dist/node/components/ErrorBoundary/index.d.ts.map +1 -1
- package/dist/node/components/ErrorRender/ErrorAlert.d.cts +2 -1
- package/dist/node/components/ErrorRender/ErrorAlert.d.cts.map +1 -1
- package/dist/node/components/ErrorRender/ErrorAlert.d.mts +2 -1
- package/dist/node/components/ErrorRender/ErrorAlert.d.mts.map +1 -1
- package/dist/node/components/ErrorRender/ErrorAlert.d.ts +2 -1
- package/dist/node/components/ErrorRender/ErrorAlert.d.ts.map +1 -1
- package/dist/node/components/ErrorRender/Render.d.cts +2 -1
- package/dist/node/components/ErrorRender/Render.d.cts.map +1 -1
- package/dist/node/components/ErrorRender/Render.d.mts +2 -1
- package/dist/node/components/ErrorRender/Render.d.mts.map +1 -1
- package/dist/node/components/ErrorRender/Render.d.ts +2 -1
- package/dist/node/components/ErrorRender/Render.d.ts.map +1 -1
- package/dist/node/components/ErrorRender/index.d.cts +3 -3
- package/dist/node/components/ErrorRender/index.d.cts.map +1 -1
- package/dist/node/components/ErrorRender/index.d.mts +3 -3
- package/dist/node/components/ErrorRender/index.d.mts.map +1 -1
- package/dist/node/components/ErrorRender/index.d.ts +3 -3
- package/dist/node/components/ErrorRender/index.d.ts.map +1 -1
- package/dist/node/components/index.d.cts +2 -2
- package/dist/node/components/index.d.mts +2 -2
- package/dist/node/components/index.d.ts +2 -2
- package/dist/node/contexts/ErrorReporter/Context.d.cts +1 -1
- package/dist/node/contexts/ErrorReporter/Context.d.mts +1 -1
- package/dist/node/contexts/ErrorReporter/Context.d.ts +1 -1
- package/dist/node/contexts/ErrorReporter/Provider.d.cts +1 -0
- package/dist/node/contexts/ErrorReporter/Provider.d.cts.map +1 -1
- package/dist/node/contexts/ErrorReporter/Provider.d.mts +1 -0
- package/dist/node/contexts/ErrorReporter/Provider.d.mts.map +1 -1
- package/dist/node/contexts/ErrorReporter/Provider.d.ts +1 -0
- package/dist/node/contexts/ErrorReporter/Provider.d.ts.map +1 -1
- package/dist/node/contexts/ErrorReporter/index.d.cts +3 -3
- package/dist/node/contexts/ErrorReporter/index.d.cts.map +1 -1
- package/dist/node/contexts/ErrorReporter/index.d.mts +3 -3
- package/dist/node/contexts/ErrorReporter/index.d.mts.map +1 -1
- package/dist/node/contexts/ErrorReporter/index.d.ts +3 -3
- package/dist/node/contexts/ErrorReporter/index.d.ts.map +1 -1
- package/dist/node/contexts/ErrorReporter/useRollbar.d.cts +1 -1
- package/dist/node/contexts/ErrorReporter/useRollbar.d.mts +1 -1
- package/dist/node/contexts/ErrorReporter/useRollbar.d.ts +1 -1
- package/dist/node/contexts/index.d.cts +1 -1
- package/dist/node/contexts/index.d.mts +1 -1
- package/dist/node/contexts/index.d.ts +1 -1
- package/dist/node/index.cjs +101 -52
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +2 -2
- package/dist/node/index.d.mts +2 -2
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.mjs +162 -0
- package/dist/node/index.mjs.map +1 -0
- package/package.json +13 -13
- package/src/components/ErrorBoundary/ThrownErrorBoundary.stories.tsx +8 -4
- package/src/components/ErrorBoundary/ThrownErrorBoundary.tsx +8 -7
- package/src/components/ErrorBoundary/index.ts +1 -1
- package/src/components/ErrorRender/ErrorAlert.stories.tsx +41 -0
- package/src/components/ErrorRender/ErrorAlert.tsx +35 -24
- 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/dist/browser/index.js +0 -121
- package/dist/browser/index.js.map +0 -1
- package/dist/neutral/index.js +0 -121
- package/dist/neutral/index.js.map +0 -1
- package/dist/node/index.js +0 -121
- package/dist/node/index.js.map +0 -1
package/dist/node/index.js
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
// src/components/ErrorBoundary/ThrownErrorBoundary.tsx
|
2
|
-
import { ModuleErrorSchema } from "@xyo-network/payload-model";
|
3
|
-
import { Component } from "react";
|
4
|
-
|
5
|
-
// src/components/ErrorRender/ErrorAlert.tsx
|
6
|
-
import { ExitToApp as ExitIcon } from "@mui/icons-material";
|
7
|
-
import { Alert, AlertTitle, Typography } from "@mui/material";
|
8
|
-
import { ButtonEx } from "@xylabs/react-button";
|
9
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
10
|
-
var ErrorAlert = ({ onCancel, error, errorContext, scope, ...props }) => {
|
11
|
-
return /* @__PURE__ */ jsxs(Alert, { severity: "error", ...props, children: [
|
12
|
-
/* @__PURE__ */ jsx(AlertTitle, { children: "Whoops! Something went wrong" }),
|
13
|
-
errorContext ? /* @__PURE__ */ jsx(Typography, { variant: "caption", my: 0.5, lineHeight: "1", display: "block", children: errorContext }) : null,
|
14
|
-
scope ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
15
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", mr: 0.5, fontWeight: "bold", children: "Scope:" }),
|
16
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", children: scope })
|
17
|
-
] }) : null,
|
18
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", mr: 0.5, fontWeight: "bold", children: "Error:" }),
|
19
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", children: error == null ? void 0 : error.message }),
|
20
|
-
onCancel ? /* @__PURE__ */ jsx(ButtonEx, { variant: "outlined", size: "small", onClick: onCancel, position: "absolute", style: { right: 8, top: 8 }, children: /* @__PURE__ */ jsx(ExitIcon, { fontSize: "small" }) }) : null
|
21
|
-
] });
|
22
|
-
};
|
23
|
-
|
24
|
-
// src/components/ErrorRender/Render.tsx
|
25
|
-
import { FlexCol } from "@xylabs/react-flexbox";
|
26
|
-
import { useEffect } from "react";
|
27
|
-
import { Fragment as Fragment2, jsx as jsx2 } from "react/jsx-runtime";
|
28
|
-
var ErrorRender = ({
|
29
|
-
onCancel,
|
30
|
-
error,
|
31
|
-
noErrorDisplay = false,
|
32
|
-
customError = null,
|
33
|
-
children,
|
34
|
-
errorContext,
|
35
|
-
scope,
|
36
|
-
useLocation,
|
37
|
-
...props
|
38
|
-
}) => {
|
39
|
-
const location = useLocation == null ? void 0 : useLocation();
|
40
|
-
useEffect(() => {
|
41
|
-
if (location) {
|
42
|
-
location.state = {
|
43
|
-
from: {
|
44
|
-
pathname: window.location.pathname
|
45
|
-
}
|
46
|
-
};
|
47
|
-
}
|
48
|
-
}, [location]);
|
49
|
-
return error ? /* @__PURE__ */ jsx2(FlexCol, { alignItems: "stretch", ...props, children: noErrorDisplay ? customError : /* @__PURE__ */ jsx2(FlexCol, { alignItems: "center", ...props, children: /* @__PURE__ */ jsx2(ErrorAlert, { error, errorContext, onCancel, scope }) }) }) : /* @__PURE__ */ jsx2(Fragment2, { children }) ?? null;
|
50
|
-
};
|
51
|
-
|
52
|
-
// src/components/ErrorBoundary/ThrownErrorBoundary.tsx
|
53
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
54
|
-
var ThrownErrorBoundary = class _ThrownErrorBoundary extends Component {
|
55
|
-
state = {
|
56
|
-
xyoError: void 0
|
57
|
-
};
|
58
|
-
static getDerivedStateFromError(error) {
|
59
|
-
return { hasError: true, xyoError: _ThrownErrorBoundary.normalizeError(error) };
|
60
|
-
}
|
61
|
-
static normalizeError(error) {
|
62
|
-
return error.schema === ModuleErrorSchema ? error : { message: error.message, schema: ModuleErrorSchema, sources: [] };
|
63
|
-
}
|
64
|
-
componentDidCatch(error, errorInfo) {
|
65
|
-
const { rethrow, rollbar } = this.props;
|
66
|
-
const { xyoError } = this.state;
|
67
|
-
rollbar == null ? void 0 : rollbar.error(error);
|
68
|
-
console.error("Error:", xyoError, errorInfo);
|
69
|
-
if (rethrow) {
|
70
|
-
throw error;
|
71
|
-
}
|
72
|
-
}
|
73
|
-
render() {
|
74
|
-
const { xyoError } = this.state;
|
75
|
-
const { children, boundaryName, errorComponent, scope } = this.props;
|
76
|
-
if (xyoError) {
|
77
|
-
if (errorComponent) {
|
78
|
-
return errorComponent(xyoError);
|
79
|
-
}
|
80
|
-
return /* @__PURE__ */ jsx3(ErrorRender, { error: xyoError, errorContext: `${boundaryName} Boundary`, scope });
|
81
|
-
}
|
82
|
-
return children;
|
83
|
-
}
|
84
|
-
};
|
85
|
-
|
86
|
-
// src/contexts/ErrorReporter/Provider.tsx
|
87
|
-
import { useEffect as useEffect2, useState } from "react";
|
88
|
-
|
89
|
-
// src/contexts/ErrorReporter/Context.ts
|
90
|
-
import { createContext } from "react";
|
91
|
-
var ErrorReporterContext = createContext({});
|
92
|
-
|
93
|
-
// src/contexts/ErrorReporter/Provider.tsx
|
94
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
95
|
-
var ErrorReporterProvider = ({ children, rollbar }) => {
|
96
|
-
const [rollbarInstance, setRollBarInstance] = useState();
|
97
|
-
useEffect2(() => {
|
98
|
-
if (rollbarInstance) {
|
99
|
-
setRollBarInstance(rollbarInstance);
|
100
|
-
}
|
101
|
-
}, [rollbar, rollbarInstance]);
|
102
|
-
return /* @__PURE__ */ jsx4(ErrorReporterContext.Provider, { value: { rollbar }, children });
|
103
|
-
};
|
104
|
-
|
105
|
-
// src/contexts/ErrorReporter/useRollbar.tsx
|
106
|
-
import { useContext } from "react";
|
107
|
-
var useRollbar = () => {
|
108
|
-
const context = useContext(ErrorReporterContext);
|
109
|
-
if (context === void 0) {
|
110
|
-
console.warn("useRollbar must be used within a ErrorReporterContext");
|
111
|
-
}
|
112
|
-
return context ?? {};
|
113
|
-
};
|
114
|
-
export {
|
115
|
-
ErrorAlert,
|
116
|
-
ErrorRender,
|
117
|
-
ErrorReporterProvider,
|
118
|
-
ThrownErrorBoundary,
|
119
|
-
useRollbar
|
120
|
-
};
|
121
|
-
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
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 { Component, ErrorInfo, ReactNode } from 'react'\nimport Rollbar from 'rollbar'\n\nimport { ErrorRender } from '../ErrorRender/index.js'\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}\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 } = this.props\n if (xyoError) {\n if (errorComponent) {\n return errorComponent(xyoError)\n }\n return <ErrorRender error={xyoError} errorContext={`${boundaryName} Boundary`} scope={scope} />\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'\n\nexport interface ErrorAlertProps extends AlertProps {\n error?: ModuleError | Error\n errorContext?: string\n onCancel?: () => void\n scope?: string\n}\n\nexport const ErrorAlert: React.FC<ErrorAlertProps> = ({ onCancel, error, errorContext, scope, ...props }) => {\n return (\n <Alert severity=\"error\" {...props}>\n <AlertTitle>Whoops! Something went wrong</AlertTitle>\n {errorContext ?\n <Typography variant=\"caption\" my={0.5} lineHeight=\"1\" display=\"block\">\n {errorContext}\n </Typography>\n : null}\n {scope ?\n <>\n <Typography variant=\"caption\" mr={0.5} fontWeight=\"bold\">\n Scope:\n </Typography>\n <Typography variant=\"caption\">{scope}</Typography>\n </>\n : null}\n <Typography variant=\"caption\" mr={0.5} fontWeight=\"bold\">\n Error:\n </Typography>\n <Typography variant=\"caption\">{error?.message}</Typography>\n {onCancel ?\n <ButtonEx variant=\"outlined\" size=\"small\" onClick={onCancel} position=\"absolute\" style={{ right: 8, top: 8 }}>\n <ExitIcon fontSize=\"small\" />\n </ButtonEx>\n : null}\n </Alert>\n )\n}\n","import { FlexCol } from '@xylabs/react-flexbox'\nimport { useEffect } from 'react'\n\nimport { ErrorAlert } from './ErrorAlert.js'\nimport { ErrorRenderProps } from './Props.js'\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 <FlexCol alignItems=\"stretch\" {...props}>\n {noErrorDisplay ?\n customError\n : <FlexCol alignItems=\"center\" {...props}>\n <ErrorAlert error={error} errorContext={errorContext} onCancel={onCancel} scope={scope} />\n </FlexCol>\n }\n </FlexCol>\n : (<>{children}</> ?? null)\n}\n","import { WithChildren } from '@xylabs/react-shared'\nimport { useEffect, useState } from 'react'\nimport Rollbar from 'rollbar'\n\nimport { ErrorReporterContext } from './Context.js'\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 return <ErrorReporterContext.Provider value={{ rollbar }}>{children}</ErrorReporterContext.Provider>\n}\n\nexport { ErrorReporterProvider }\n","import { createContext } from 'react'\n\nimport { ErrorReporterContextState } from './State.js'\n\nexport const ErrorReporterContext = createContext<ErrorReporterContextState>({})\n","import { useContext } from 'react'\n\nimport { ErrorReporterContext } from './Context.js'\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":";AAAA,SAAsB,yBAAyB;AAC/C,SAAS,iBAAuC;;;ACDhD,SAAS,aAAa,gBAAg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