add dispatch try catch (#3075)
This commit is contained in:
parent
a9ee6e6a5e
commit
10421d73f4
@ -37,7 +37,7 @@ import { dispatchQueryExtension } from './tools/queryExternsion';
|
|||||||
import { dispatchRunPlugin } from './plugin/run';
|
import { dispatchRunPlugin } from './plugin/run';
|
||||||
import { dispatchPluginInput } from './plugin/runInput';
|
import { dispatchPluginInput } from './plugin/runInput';
|
||||||
import { dispatchPluginOutput } from './plugin/runOutput';
|
import { dispatchPluginOutput } from './plugin/runOutput';
|
||||||
import { removeSystemVariable, valueTypeFormat } from './utils';
|
import { formatHttpError, removeSystemVariable, valueTypeFormat } from './utils';
|
||||||
import {
|
import {
|
||||||
filterWorkflowEdges,
|
filterWorkflowEdges,
|
||||||
checkNodeRunStatus,
|
checkNodeRunStatus,
|
||||||
@ -72,6 +72,7 @@ import { dispatchLoopEnd } from './loop/runLoopEnd';
|
|||||||
import { dispatchLoopStart } from './loop/runLoopStart';
|
import { dispatchLoopStart } from './loop/runLoopStart';
|
||||||
import { dispatchFormInput } from './interactive/formInput';
|
import { dispatchFormInput } from './interactive/formInput';
|
||||||
import { dispatchToolParams } from './agent/runTool/toolParams';
|
import { dispatchToolParams } from './agent/runTool/toolParams';
|
||||||
|
import { responseWrite } from '../../../common/response';
|
||||||
|
|
||||||
const callbackMap: Record<FlowNodeTypeEnum, Function> = {
|
const callbackMap: Record<FlowNodeTypeEnum, Function> = {
|
||||||
[FlowNodeTypeEnum.workflowStart]: dispatchWorkflowStart,
|
[FlowNodeTypeEnum.workflowStart]: dispatchWorkflowStart,
|
||||||
@ -548,7 +549,21 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
|||||||
// run module
|
// run module
|
||||||
const dispatchRes: Record<string, any> = await (async () => {
|
const dispatchRes: Record<string, any> = await (async () => {
|
||||||
if (callbackMap[node.flowNodeType]) {
|
if (callbackMap[node.flowNodeType]) {
|
||||||
return callbackMap[node.flowNodeType](dispatchData);
|
try {
|
||||||
|
return await callbackMap[node.flowNodeType](dispatchData);
|
||||||
|
} catch (error) {
|
||||||
|
// Get source handles of outgoing edges
|
||||||
|
const targetEdges = runtimeEdges.filter((item) => item.source === node.nodeId);
|
||||||
|
const skipHandleIds = targetEdges.map((item) => item.sourceHandle);
|
||||||
|
|
||||||
|
// Skip all edges and return error
|
||||||
|
return {
|
||||||
|
[DispatchNodeResponseKeyEnum.nodeResponse]: {
|
||||||
|
error: formatHttpError(error)
|
||||||
|
},
|
||||||
|
[DispatchNodeResponseKeyEnum.skipHandleId]: skipHandleIds
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
})();
|
})();
|
||||||
|
|||||||
@ -525,6 +525,12 @@ const ChatBox = (
|
|||||||
generatingMessage: (e) => generatingMessage({ ...e, autoTTSResponse }),
|
generatingMessage: (e) => generatingMessage({ ...e, autoTTSResponse }),
|
||||||
variables: requestVariables
|
variables: requestVariables
|
||||||
});
|
});
|
||||||
|
if (responseData?.[responseData.length - 1]?.error) {
|
||||||
|
toast({
|
||||||
|
title: responseData[responseData.length - 1].error?.message,
|
||||||
|
status: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
isNewChatReplace.current = isNewChat;
|
isNewChatReplace.current = isNewChat;
|
||||||
|
|
||||||
|
|||||||
@ -235,6 +235,12 @@ const PluginRunContextProvider = ({
|
|||||||
...variables
|
...variables
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (responseData?.[responseData.length - 1]?.error) {
|
||||||
|
toast({
|
||||||
|
title: responseData[responseData.length - 1].error?.message,
|
||||||
|
status: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
setHistories((state) =>
|
setHistories((state) =>
|
||||||
state.map((item, index) => {
|
state.map((item, index) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user