mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-04-08 03:48:14 +02:00
Fix indexing status page crashing
This commit is contained in:
parent
09da456bba
commit
f6fb963419
@ -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<ConnectorIndexingStatus<any, any>[]>(
|
||||
"/api/manage/admin/connector/indexing-status",
|
||||
fetcher,
|
||||
errorHandlingFetcher,
|
||||
{ refreshInterval: 10000 } // 10 seconds
|
||||
);
|
||||
|
||||
@ -26,15 +26,19 @@ function Main() {
|
||||
return <LoadingAnimation text="" />;
|
||||
}
|
||||
|
||||
if (indexAttemptIsError || !indexAttemptData) {
|
||||
return <div className="text-red-600">Error loading indexing history.</div>;
|
||||
if (indexAttemptError || !indexAttemptData) {
|
||||
return (
|
||||
<div className="text-error">
|
||||
{indexAttemptError?.info?.detail || "Error loading indexing history."}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (indexAttemptData.length === 0) {
|
||||
return (
|
||||
<Text>
|
||||
It looks like you don't have any connectors setup yet. Visit the{" "}
|
||||
<Link className="text-blue-500" href="/admin/add-connector">
|
||||
<Link className="text-link" href="/admin/add-connector">
|
||||
Add Connector
|
||||
</Link>{" "}
|
||||
page to get started!
|
||||
|
@ -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()
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user