calcom/pages/sandbox/test-error.tsx
Mihai C 903f7729c7
feat: add better error handling (#605)
* feat: add better error handling

* refactor: update after review

* refactor: remove unnecessary code

* refactor: better path structure

* refactor: fetch-wrapper after code review

Co-authored-by: Mihai Colceriu <colceriumi@gmail.com>
2021-09-09 16:51:06 +03:00

28 lines
843 B
TypeScript

import React from "react";
import { HttpError } from "@lib/core/http/error";
type Props = {
hasRunOnServer: boolean;
};
const TestErrorRoute: React.FC<Props> = (props) => {
if (!props.hasRunOnServer) {
throw new HttpError({ statusCode: 400, message: "test-error.tsx" });
}
return <>If you see this message, there is really something wrong ;)</>;
};
// Having a page that always throws error is very hard with nextjs
// because it will try to pre-render the page at build-time... and
// complain: 'you need to fix this'. So here because we want to always
// throw an error for monitoring, let's force server side generation
// all the time (the page won't be pre-generated, all cool).
export async function getServerSideProps() {
return {
props: {
hasRunOnServer: false,
},
};
}
export default TestErrorRoute;