chore: error handler
This commit is contained in:
parent
b42f906029
commit
0352448381
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -14,5 +14,6 @@
|
|||
"username": "root",
|
||||
"password": "123456"
|
||||
}
|
||||
]
|
||||
],
|
||||
"commentTranslate.targetLanguage": "zh-CN"
|
||||
}
|
30
app/1global-error.tsx
Normal file
30
app/1global-error.tsx
Normal file
|
@ -0,0 +1,30 @@
|
|||
"use client"; // Error components must be Client Components
|
||||
|
||||
import { useEffect } from "react";
|
||||
|
||||
export default function Error({
|
||||
error,
|
||||
reset,
|
||||
}: {
|
||||
error: Error & { digest?: string };
|
||||
reset: () => void;
|
||||
}) {
|
||||
useEffect(() => {
|
||||
// Log the error to an error reporting service
|
||||
console.error(error);
|
||||
}, [error]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2>Something went wrong!</h2>
|
||||
<button
|
||||
onClick={
|
||||
// Attempt to recover by trying to re-render the segment
|
||||
() => reset()
|
||||
}
|
||||
>
|
||||
Try again
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
|
@ -10,6 +10,8 @@ import QuillWrapper from "./QuillWrapper";
|
|||
// import TinyEditor from "../components/TinyEditor";
|
||||
// import SEditor from "../components/SlateEditor";
|
||||
import SettingsLink from "@/components/SettingsLink";
|
||||
import { ErrorBoundary } from "next/dist/client/components/error-boundary";
|
||||
import Error from "@/app/global-error";
|
||||
export default async function Index() {
|
||||
const cookieStore = cookies();
|
||||
|
||||
|
@ -35,8 +37,9 @@ export default async function Index() {
|
|||
<SettingsLink />
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
{/* <ErrorBoundary fallback={<Error />}> */}
|
||||
<QuillWrapper />
|
||||
{/* </ErrorBoundary> */}
|
||||
|
||||
<footer className="w-full border-t border-t-foreground/10 p-8 flex justify-center text-center text-xs">
|
||||
<p>
|
||||
|
|
Loading…
Reference in New Issue
Block a user