cal/pages/sandbox/test-async-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

26 lines
683 B
TypeScript

import React from "react";
import { HttpError } from "@lib/core/http/error";
import { useQuery } from "react-query";
const TestAsyncErrorRoute: React.FC = () => {
const { error, isLoading } = useQuery(["error-promise"], async () => {
throw new HttpError({
statusCode: 400,
message: "A http error occurred on the client side in test-async-error.tsx.",
url: "http://awebsite.that.does.not.exist",
});
});
if (isLoading) {
return <>Loading...</>;
}
if (error) {
console.log("An error occurred", error);
throw error;
}
return <>If you see this message, there is really something wrong ;)</>;
};
export default TestAsyncErrorRoute;