From e9c5c16bfd98e5defea455e8fb0fd1f0bba08ec5 Mon Sep 17 00:00:00 2001 From: Rodney Norris Date: Thu, 22 Dec 2022 16:31:56 -0600 Subject: [PATCH] [Enterprise Search] updated simulate endpoints to return error from simulate (#147898) ## Summary Updated the two simulate endpoints to return an error with the underlying simulate error instead of throwing the error up to the default handler. image --- .../server/routes/enterprise_search/indices.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/enterprise_search/server/routes/enterprise_search/indices.ts b/x-pack/plugins/enterprise_search/server/routes/enterprise_search/indices.ts index bc4c644e8666..b1ffa830a9a8 100644 --- a/x-pack/plugins/enterprise_search/server/routes/enterprise_search/indices.ts +++ b/x-pack/plugins/enterprise_search/server/routes/enterprise_search/indices.ts @@ -596,8 +596,12 @@ export function registerIndexRoutes({ headers: { 'content-type': 'application/json' }, }); } catch (e) { - log.error(`Error simulating inference pipeline: ${JSON.stringify(e)}`); - throw e; + return createError({ + errorCode: ErrorCode.UNCAUGHT_EXCEPTION, + message: e.message, + response, + statusCode: 400, + }); } }) ); @@ -673,8 +677,12 @@ export function registerIndexRoutes({ headers: { 'content-type': 'application/json' }, }); } catch (e) { - log.error(`Error simulating inference pipeline: ${JSON.stringify(e)}`); - throw e; + return createError({ + errorCode: ErrorCode.UNCAUGHT_EXCEPTION, + message: e.message, + response, + statusCode: 400, + }); } }) );