Files
stop-shoping-web/src/pages/Error/index.tsx
2026-03-25 14:59:06 +08:00

45 lines
942 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import {
useRouteError,
type ErrorResponse,
isRouteErrorResponse,
} from "react-router";
export function ErrorPage() {
const error = useRouteError();
if (isRouteErrorResponse(error)) {
const statusError = error as ErrorResponse;
if (statusError.status == 404) {
return (
<div>
<h1></h1>
</div>
);
} else {
return (
<div>
<h1></h1>
<h3>{statusError.status}</h3>
<h3>{statusError.statusText}</h3>
<h3>{JSON.stringify(statusError.data)}</h3>
</div>
);
}
} else if (error instanceof Error) {
const err = error as Error;
return (
<div>
<h1></h1>
<h3>{err.name}</h3>
<h3>{err.message}</h3>
</div>
);
} else {
return (
<div>
<h1></h1>
</div>
);
}
}