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

### What problem does this PR solve?

feat: Catch errors in getting mindmap #2247

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu 2024-09-11 16:19:14 +08:00 committed by GitHub
parent f789098e9f
commit 8e3228d461
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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);
try {
const ret = await chatService.getMindMap(params);
return ret?.data?.data ?? [];
} catch (error) {
if (has(error, 'message')) {
message.error(error.message);
}
return data?.data ?? [];
return [];
}
},
});