diff --git a/server/routes/text2viz_routes.ts b/server/routes/text2viz_routes.ts index 0b7c61f6..6db25c55 100644 --- a/server/routes/text2viz_routes.ts +++ b/server/routes/text2viz_routes.ts @@ -86,11 +86,20 @@ export function registerText2VizRoutes(router: IRouter, assistantService: Assist } return res.badRequest(); } 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, + }); + } } }) );