-
Notifications
You must be signed in to change notification settings - Fork 881
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Innei <i@innei.in>
- Loading branch information
Showing
6 changed files
with
88 additions
and
35 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
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { attachOpenInEditor } from "@renderer/lib/dev" | ||
import type { FallbackRender } from "@sentry/react" | ||
import type { FC } from "react" | ||
|
||
import { FallbackIssue } from "../common/ErrorElement" | ||
import { StyledButton } from "../ui/button" | ||
import { parseError } from "./helper" | ||
|
||
export const PageErrorFallback: FC<Parameters<FallbackRender>[0]> = (props) => { | ||
const { message, stack } = parseError(props.error) | ||
|
||
return ( | ||
<div className="flex w-full flex-col items-center justify-center rounded-md bg-theme-modal-background-opaque p-2"> | ||
<div className="m-auto max-w-prose text-center"> | ||
<div className="mb-4"> | ||
<i className="i-mgc-bug-cute-re text-4xl text-red-500" /> | ||
</div> | ||
<div className="text-lg font-bold">{message}</div> | ||
{import.meta.env.DEV && stack ? ( | ||
<div className="mt-4 cursor-text overflow-auto whitespace-pre rounded-md bg-red-50 p-4 text-left font-mono text-sm text-red-600"> | ||
{attachOpenInEditor(stack)} | ||
</div> | ||
) : null} | ||
|
||
<p className="my-8"> | ||
The App has a temporary problem, click the button below to try | ||
reloading the app or another solution? | ||
</p> | ||
|
||
<div className="center gap-4"> | ||
<StyledButton onClick={() => props.resetError()} variant="primary"> | ||
Reset | ||
</StyledButton> | ||
|
||
<StyledButton | ||
onClick={() => window.location.reload()} | ||
variant="outline" | ||
> | ||
Reload | ||
</StyledButton> | ||
</div> | ||
|
||
<FallbackIssue message={message!} stack={stack} /> | ||
</div> | ||
</div> | ||
) | ||
} |
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,11 +1,15 @@ | ||
import { ModalErrorFallback } from "./ModalError" | ||
import { PageErrorFallback } from "./PageError" | ||
|
||
export enum ErrorComponentType { | ||
Modal = "Modal", | ||
Page = "Page", | ||
} | ||
|
||
export const ErrorFallbackMap = { | ||
[ErrorComponentType.Modal]: ModalErrorFallback, | ||
[ErrorComponentType.Page]: PageErrorFallback, | ||
} | ||
|
||
export const getErrorFallback = (type: ErrorComponentType) => ErrorFallbackMap[type] | ||
export const getErrorFallback = (type: ErrorComponentType) => | ||
ErrorFallbackMap[type] |
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