-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
58 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@solidjs/start": patch | ||
--- | ||
|
||
fix up top level errorboundary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,52 @@ | ||
// @refresh skip | ||
import { ErrorBoundary as DefaultErrorBoundary, type ParentProps } from "solid-js"; | ||
import { ErrorBoundary as DefaultErrorBoundary, catchError, type ParentProps } from "solid-js"; | ||
import { isServer } from "solid-js/web"; | ||
import { HttpStatusCode } from "./HttpStatusCode"; | ||
import { DevOverlay } from "./dev-overlay"; | ||
|
||
export const ErrorBoundary = import.meta.env.DEV && import.meta.env.START_DEV_OVERLAY | ||
? (props: ParentProps) => <DevOverlay>{props.children}</DevOverlay> | ||
: (props: ParentProps) => { | ||
const message = isServer ? "500 | Internal Server Error" : "Error | Uncaught Client Exception"; | ||
return ( | ||
<DefaultErrorBoundary | ||
fallback={error => { | ||
console.error(error); | ||
return ( | ||
<> | ||
<span style="font-size:1.5em;text-align:center;position:fixed;left:0px;bottom:55%;width:100%;"> | ||
{message} | ||
</span> | ||
<HttpStatusCode code={500} /> | ||
</> | ||
); | ||
}} | ||
> | ||
{props.children} | ||
</DefaultErrorBoundary> | ||
) | ||
}; | ||
export const ErrorBoundary = | ||
import.meta.env.DEV && import.meta.env.START_DEV_OVERLAY | ||
? (props: ParentProps) => <DevOverlay>{props.children}</DevOverlay> | ||
: (props: ParentProps) => { | ||
const message = isServer | ||
? "500 | Internal Server Error" | ||
: "Error | Uncaught Client Exception"; | ||
return ( | ||
<DefaultErrorBoundary | ||
fallback={error => { | ||
console.error(error); | ||
return ( | ||
<> | ||
<span style="font-size:1.5em;text-align:center;position:fixed;left:0px;bottom:55%;width:100%;"> | ||
{message} | ||
</span> | ||
<HttpStatusCode code={500} /> | ||
</> | ||
); | ||
}} | ||
> | ||
{props.children} | ||
</DefaultErrorBoundary> | ||
); | ||
}; | ||
|
||
export const TopErrorBoundary = (props: ParentProps) => { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
let isError = false; | ||
const res = catchError( | ||
() => props.children, | ||
err => { | ||
console.error(err); | ||
isError = !!err; | ||
} | ||
); | ||
return isError ? ( | ||
<> | ||
<span style="font-size:1.5em;text-align:center;position:fixed;left:0px;bottom:55%;width:100%;"> | ||
500 | Internal Server Error | ||
</span> | ||
<HttpStatusCode code={500} /> | ||
</> | ||
) : ( | ||
res | ||
); | ||
}; |
Ah look at that, nice, thanks for fixing. Why exactly is this now better? What does this improve? :D trying to understand @ryansolid