diff --git a/web/src/app/admin/indexing/status/page.tsx b/web/src/app/admin/indexing/status/page.tsx index 15aa7929a..c1e4277ca 100644 --- a/web/src/app/admin/indexing/status/page.tsx +++ b/web/src/app/admin/indexing/status/page.tsx @@ -4,7 +4,7 @@ import useSWR from "swr"; import { LoadingAnimation } from "@/components/Loading"; import { NotebookIcon } from "@/components/icons/icons"; -import { fetcher } from "@/lib/fetcher"; +import { errorHandlingFetcher, fetcher } from "@/lib/fetcher"; import { ConnectorIndexingStatus } from "@/lib/types"; import { CCPairIndexingStatusTable } from "./CCPairIndexingStatusTable"; import { AdminPageTitle } from "@/components/admin/Title"; @@ -15,10 +15,10 @@ function Main() { const { data: indexAttemptData, isLoading: indexAttemptIsLoading, - error: indexAttemptIsError, + error: indexAttemptError, } = useSWR[]>( "/api/manage/admin/connector/indexing-status", - fetcher, + errorHandlingFetcher, { refreshInterval: 10000 } // 10 seconds ); @@ -26,15 +26,19 @@ function Main() { return ; } - if (indexAttemptIsError || !indexAttemptData) { - return
Error loading indexing history.
; + if (indexAttemptError || !indexAttemptData) { + return ( +
+ {indexAttemptError?.info?.detail || "Error loading indexing history."} +
+ ); } if (indexAttemptData.length === 0) { return ( It looks like you don't have any connectors setup yet. Visit the{" "} - + Add Connector {" "} page to get started! diff --git a/web/src/lib/fetcher.ts b/web/src/lib/fetcher.ts index e9ca26c20..99f200466 100644 --- a/web/src/lib/fetcher.ts +++ b/web/src/lib/fetcher.ts @@ -11,11 +11,13 @@ class FetchError extends Error { } } +const DEFAULT_ERROR_MSG = "An error occurred while fetching the data."; + export const errorHandlingFetcher = async (url: string) => { const res = await fetch(url); if (!res.ok) { const error = new FetchError( - "An error occurred while fetching the data.", + DEFAULT_ERROR_MSG, res.status, await res.json() );