feat: custom error page

This commit is contained in:
Aaryan Khandelwal 2023-03-24 01:11:33 +05:30
parent 2f2caaaf6e
commit ad60b8774e
2 changed files with 22 additions and 3 deletions

View File

@ -35,6 +35,8 @@ const WorkspacePage: NextPage = () => {
workspaceSlug ? () => userService.userWorkspaceDashboard(workspaceSlug as string) : null workspaceSlug ? () => userService.userWorkspaceDashboard(workspaceSlug as string) : null
); );
hi = "hi";
return ( return (
<AppLayout noHeader={true}> <AppLayout noHeader={true}>
<div className="h-full w-full"> <div className="h-full w-full">

View File

@ -19,15 +19,32 @@
import * as Sentry from "@sentry/nextjs"; import * as Sentry from "@sentry/nextjs";
import NextErrorComponent from "next/error"; import NextErrorComponent from "next/error";
const CustomErrorComponent = (props) => <NextErrorComponent statusCode={props.statusCode} />; const CustomErrorComponent = ({ statusCode }) => {
console.log(statusCode, "statusCode");
return (
<p>
We{"'"}re Sorry! An exception has been detected, and our engineering team has been notified.
We apologize for any inconvenience this may have caused. Please reach out to our engineering
team at <a href="mailto:support@plane.so">support@plane.so</a> or on our{" "}
<a href="https://discord.com/invite/A92xrEGCge" target="_blank" rel="noopener noreferrer">
Discord
</a>{" "}
server for further assistance.
</p>
);
};
CustomErrorComponent.getInitialProps = async (contextData) => { CustomErrorComponent.getInitialProps = async (contextData) => {
// In case this is running in a serverless function, await this in order to give Sentry // In case this is running in a serverless function, await this in order to give Sentry
// time to send the error before the lambda exits // time to send the error before the lambda exits
await Sentry.captureUnderscoreErrorException(contextData); await Sentry.captureUnderscoreErrorException(contextData);
// This will contain the status code of the response const { res, err } = contextData;
return NextErrorComponent.getInitialProps(contextData);
const statusCode = res ? res.statusCode : err ? err.statusCode : 404;
return { statusCode };
}; };
export default CustomErrorComponent; export default CustomErrorComponent;