|
1 | 1 | // @refresh skip |
2 | | -import { ErrorBoundary as DefaultErrorBoundary, catchError, type ParentProps } from "solid-js"; |
| 2 | +import { |
| 3 | + catchError, |
| 4 | + ErrorBoundary as DefaultErrorBoundary, |
| 5 | + type ParentProps, |
| 6 | +} from "solid-js"; |
3 | 7 | import { isServer } from "solid-js/web"; |
4 | | -import { HttpStatusCode } from "./HttpStatusCode.ts"; |
5 | 8 | import { DevOverlay } from "./dev-overlay/index.tsx"; |
| 9 | +import { HttpStatusCode } from "./HttpStatusCode.ts"; |
| 10 | +import { ServerFunctionInspector } from "./server-function-inspector/index.tsx"; |
6 | 11 |
|
7 | 12 | export const ErrorBoundary = |
8 | 13 | import.meta.env.DEV && import.meta.env.START_DEV_OVERLAY |
9 | | - ? (props: ParentProps) => <DevOverlay>{props.children}</DevOverlay> |
| 14 | + ? (props: ParentProps) => ( |
| 15 | + <DevOverlay> |
| 16 | + <ServerFunctionInspector /> |
| 17 | + {props.children} |
| 18 | + </DevOverlay> |
| 19 | + ) |
10 | 20 | : (props: ParentProps) => { |
11 | | - const message = isServer |
12 | | - ? "500 | Internal Server Error" |
13 | | - : "Error | Uncaught Client Exception"; |
14 | | - return ( |
15 | | - <DefaultErrorBoundary |
16 | | - fallback={error => { |
17 | | - console.error(error); |
18 | | - return ( |
19 | | - <> |
20 | | - <span style="font-size:1.5em;text-align:center;position:fixed;left:0px;bottom:55%;width:100%;"> |
21 | | - {message} |
22 | | - </span> |
23 | | - <HttpStatusCode code={500} /> |
24 | | - </> |
25 | | - ); |
26 | | - }} |
27 | | - > |
28 | | - {props.children} |
29 | | - </DefaultErrorBoundary> |
30 | | - ); |
31 | | - }; |
| 21 | + const message = isServer |
| 22 | + ? "500 | Internal Server Error" |
| 23 | + : "Error | Uncaught Client Exception"; |
| 24 | + return ( |
| 25 | + <DefaultErrorBoundary |
| 26 | + fallback={(error) => { |
| 27 | + console.error(error); |
| 28 | + return ( |
| 29 | + <> |
| 30 | + <span style="font-size:1.5em;text-align:center;position:fixed;left:0px;bottom:55%;width:100%;"> |
| 31 | + {message} |
| 32 | + </span> |
| 33 | + <HttpStatusCode code={500} /> |
| 34 | + </> |
| 35 | + ); |
| 36 | + }} |
| 37 | + > |
| 38 | + {props.children} |
| 39 | + </DefaultErrorBoundary> |
| 40 | + ); |
| 41 | + }; |
32 | 42 |
|
33 | 43 | export const TopErrorBoundary = (props: ParentProps) => { |
34 | 44 | let isError = false; |
35 | 45 | const res = catchError( |
36 | 46 | () => props.children, |
37 | | - err => { |
| 47 | + (err) => { |
38 | 48 | console.error(err); |
39 | 49 | isError = !!err; |
40 | 50 | }, |
|
0 commit comments