Skip to content

Commit c6f5d5e

Browse files
authored
Merge pull request #682 from nidhish-srivastava/fix/pageerrorhandling
Handled error on /documents page if there is error fetching documents from server
2 parents b513528 + 9e836f1 commit c6f5d5e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pages/documents/index.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useTeam } from "@/context/team-context";
22
import { FolderPlusIcon, PlusIcon } from "lucide-react";
3-
3+
import ErrorPage from "next/error";
44
import { AddDocumentModal } from "@/components/documents/add-document-modal";
55
import { DocumentsList } from "@/components/documents/documents-list";
66
import { AddFolderModal } from "@/components/folders/add-folder-modal";
@@ -11,10 +11,17 @@ import { Separator } from "@/components/ui/separator";
1111
import useDocuments, { useRootFolders } from "@/lib/swr/use-documents";
1212

1313
export default function Documents() {
14-
const { documents } = useDocuments();
14+
const { documents,error } = useDocuments();
1515
const { folders } = useRootFolders();
1616
const teamInfo = useTeam();
1717

18+
if (error && error.status === 404) {
19+
return <ErrorPage statusCode={404} />;
20+
}
21+
if (error && error.status === 500) {
22+
return <ErrorPage statusCode={500} />;
23+
}
24+
1825
return (
1926
<AppLayout>
2027
<div className="sticky top-0 z-50 bg-white p-4 pb-0 dark:bg-gray-900 sm:mx-4 sm:pt-8">

0 commit comments

Comments
 (0)