Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

feat: Catch errors in getting mindmap #2247 (#2368)

balibabu8e3228d46130
diff --git a/web/src/hooks/chat-hooks.ts b/web/src/hooks/chat-hooks.ts
index 1d4205c373..bdd5b167ed 100644
--- a/web/src/hooks/chat-hooks.ts
+++ b/web/src/hooks/chat-hooks.ts
@@ -16,7 +16,7 @@ import { buildMessageListWithUuid, isConversationIdExist } from '@/utils/chat';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { message } from 'antd';
import dayjs, { Dayjs } from 'dayjs';
-import { set } from 'lodash';
+import { has, set } from 'lodash';
import { useCallback, useMemo, useState } from 'react';
import { useSearchParams } from 'umi';
@@ -492,9 +492,16 @@ export const useFetchMindMap = () => {
mutationKey: ['fetchMindMap'],
gcTime: 0,
mutationFn: async (params: IAskRequestBody) => {
- const { data } = await chatService.getMindMap(params);
-
- return data?.data ?? [];
+ try {
+ const ret = await chatService.getMindMap(params);
+ return ret?.data?.data ?? [];
+ } catch (error) {
+ if (has(error, 'message')) {
+ message.error(error.message);
+ }
+
+ return [];
+ }
},
});