diff --git a/server/routes/agent_routes.ts b/server/routes/agent_routes.ts index 2d351145..c8a9f3eb 100644 --- a/server/routes/agent_routes.ts +++ b/server/routes/agent_routes.ts @@ -39,7 +39,7 @@ export function registerAgentRoutes(router: IRouter, assistantService: Assistant ); return res.ok({ body: response }); } catch (e) { - context.assistant_plugin.logger.debug('Execute agent failed!', e); + context.assistant_plugin.logger.error('Execute agent failed!', e); if (e.statusCode >= 400 && e.statusCode <= 499) { return res.customError({ body: e.body, diff --git a/server/routes/summary_routes.ts b/server/routes/summary_routes.ts index 8c8fc3e2..df093512 100644 --- a/server/routes/summary_routes.ts +++ b/server/routes/summary_routes.ts @@ -58,11 +58,20 @@ export function registerSummaryAssistantRoutes( topNLogPatternData: req.body.topNLogPatternData, }); } catch (e) { - return res.customError({ - body: e.body || 'execute agent failed', - statusCode: e.statusCode || 500, - headers: e.headers, - }); + context.assistant_plugin.logger.error('Execute agent failed!', e); + if (e.statusCode >= 400 && e.statusCode <= 499) { + return res.customError({ + body: e.body, + statusCode: e.statusCode, + headers: e.headers, + }); + } else { + return res.customError({ + body: 'Execute agent failed!', + statusCode: 500, + headers: e.headers, + }); + } } let summary; @@ -126,11 +135,20 @@ export function registerSummaryAssistantRoutes( question: req.body.question, }); } catch (e) { - return res.customError({ - body: e.body || 'execute agent failed', - statusCode: e.statusCode || 500, - headers: e.headers, - }); + context.assistant_plugin.logger.error('Execute agent failed!', e); + if (e.statusCode >= 400 && e.statusCode <= 499) { + return res.customError({ + body: e.body, + statusCode: e.statusCode, + headers: e.headers, + }); + } else { + return res.customError({ + body: 'Execute agent failed!', + statusCode: 500, + headers: e.headers, + }); + } } try { @@ -191,11 +209,20 @@ export function registerData2SummaryRoutes( const result = response.body.inference_results[0].output[0].result; return res.ok({ body: result }); } catch (e) { - return res.customError({ - body: e.body || 'execute agent failed', - statusCode: e.statusCode || 500, - headers: e.headers, - }); + context.assistant_plugin.logger.error('Execute agent failed!', e); + if (e.statusCode >= 400 && e.statusCode <= 499) { + return res.customError({ + body: e.body, + statusCode: e.statusCode, + headers: e.headers, + }); + } else { + return res.customError({ + body: 'Execute agent failed!', + statusCode: 500, + headers: e.headers, + }); + } } }) ); diff --git a/server/routes/text2viz_routes.ts b/server/routes/text2viz_routes.ts index c038546a..0b7c61f6 100644 --- a/server/routes/text2viz_routes.ts +++ b/server/routes/text2viz_routes.ts @@ -119,11 +119,20 @@ export function registerText2VizRoutes(router: IRouter, assistantService: Assist const result = JSON.parse(response.body.inference_results[0].output[0].result); return res.ok({ body: result }); } catch (e) { - return res.customError({ - body: e.body || 'execute agent failed', - statusCode: e.statusCode || 500, - headers: e.headers, - }); + context.assistant_plugin.logger.error('Execute agent failed!', e); + if (e.statusCode >= 400 && e.statusCode <= 499) { + return res.customError({ + body: e.body, + statusCode: e.statusCode, + headers: e.headers, + }); + } else { + return res.customError({ + body: 'Execute agent failed!', + statusCode: 500, + headers: e.headers, + }); + } } }) );