Skip to content

Commit

Permalink
feat: Catch errors in getting mindmap #2247 (#2368)
Browse files Browse the repository at this point in the history
### 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)
  • Loading branch information
cike8899 authored Sep 11, 2024
1 parent f789098 commit 8e3228d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions web/src/hooks/chat-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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 [];
}
},
});

Expand Down

0 comments on commit 8e3228d

Please sign in to comment.