diff --git a/x-pack/plugins/upgrade_assistant/server/routes/es_deprecations.test.ts b/x-pack/plugins/upgrade_assistant/server/routes/es_deprecations.test.ts index bea74f116e0e24b..4047ce827acbc35 100644 --- a/x-pack/plugins/upgrade_assistant/server/routes/es_deprecations.test.ts +++ b/x-pack/plugins/upgrade_assistant/server/routes/es_deprecations.test.ts @@ -6,6 +6,8 @@ */ import { kibanaResponseFactory } from 'src/core/server'; + +import { handleEsError } from '../shared_imports'; import { createMockRouter, MockRouter, routeHandlerContextMock } from './__mocks__/routes.mock'; import { createRequestMock } from './__mocks__/request.mock'; @@ -33,6 +35,7 @@ describe('ES deprecations API', () => { mockRouter = createMockRouter(); routeDependencies = { router: mockRouter, + lib: { handleEsError }, }; registerESDeprecationRoutes(routeDependencies); }); diff --git a/x-pack/plugins/upgrade_assistant/server/routes/es_deprecations.ts b/x-pack/plugins/upgrade_assistant/server/routes/es_deprecations.ts index eb0ade26de7660d..98089e34bdca192 100644 --- a/x-pack/plugins/upgrade_assistant/server/routes/es_deprecations.ts +++ b/x-pack/plugins/upgrade_assistant/server/routes/es_deprecations.ts @@ -11,9 +11,13 @@ import { versionCheckHandlerWrapper } from '../lib/es_version_precheck'; import { RouteDependencies } from '../types'; import { reindexActionsFactory } from '../lib/reindexing/reindex_actions'; import { reindexServiceFactory } from '../lib/reindexing'; -import { handleEsError } from '../shared_imports'; -export function registerESDeprecationRoutes({ router, licensing, log }: RouteDependencies) { +export function registerESDeprecationRoutes({ + router, + lib: { handleEsError }, + licensing, + log, +}: RouteDependencies) { router.get( { path: `${API_BASE_PATH}/es_deprecations`, @@ -50,8 +54,8 @@ export function registerESDeprecationRoutes({ router, licensing, log }: RouteDep return response.ok({ body: status, }); - } catch (e) { - return handleEsError({ error: e, response }); + } catch (error) { + return handleEsError({ error, response }); } } ) diff --git a/x-pack/plugins/upgrade_assistant/server/routes/ml_snapshots.test.ts b/x-pack/plugins/upgrade_assistant/server/routes/ml_snapshots.test.ts index 2f8cdd2aba8080c..2e53f571ee904d1 100644 --- a/x-pack/plugins/upgrade_assistant/server/routes/ml_snapshots.test.ts +++ b/x-pack/plugins/upgrade_assistant/server/routes/ml_snapshots.test.ts @@ -6,6 +6,8 @@ */ import { kibanaResponseFactory, RequestHandler } from 'src/core/server'; + +import { handleEsError } from '../shared_imports'; import { createMockRouter, MockRouter, routeHandlerContextMock } from './__mocks__/routes.mock'; import { createRequestMock } from './__mocks__/request.mock'; import { registerMlSnapshotRoutes } from './ml_snapshots'; @@ -26,6 +28,7 @@ describe('ML snapshots APIs', () => { mockRouter = createMockRouter(); routeDependencies = { router: mockRouter, + lib: { handleEsError }, }; registerMlSnapshotRoutes(routeDependencies); }); diff --git a/x-pack/plugins/upgrade_assistant/server/routes/ml_snapshots.ts b/x-pack/plugins/upgrade_assistant/server/routes/ml_snapshots.ts index f23de49d97dc87b..9611ac90c284882 100644 --- a/x-pack/plugins/upgrade_assistant/server/routes/ml_snapshots.ts +++ b/x-pack/plugins/upgrade_assistant/server/routes/ml_snapshots.ts @@ -11,7 +11,6 @@ import { IScopedClusterClient, SavedObjectsClientContract } from 'kibana/server' import { API_BASE_PATH } from '../../common/constants'; import { MlOperation, ML_UPGRADE_OP_TYPE } from '../../common/types'; import { versionCheckHandlerWrapper } from '../lib/es_version_precheck'; -import { handleEsError } from '../shared_imports'; import { RouteDependencies } from '../types'; const findMlOperation = async ( @@ -99,7 +98,7 @@ const verifySnapshotUpgrade = async ( } }; -export function registerMlSnapshotRoutes({ router }: RouteDependencies) { +export function registerMlSnapshotRoutes({ router, lib: { handleEsError } }: RouteDependencies) { // Upgrade ML model snapshot router.post( { @@ -147,8 +146,8 @@ export function registerMlSnapshotRoutes({ router }: RouteDependencies) { status: body.completed === true ? 'complete' : 'in_progress', }, }); - } catch (e) { - return handleEsError({ error: e, response }); + } catch (error) { + return handleEsError({ error, response }); } } ) diff --git a/x-pack/plugins/upgrade_assistant/server/routes/status.test.ts b/x-pack/plugins/upgrade_assistant/server/routes/status.test.ts index 36f8edb1fafeeca..8c0398ce86afcf5 100644 --- a/x-pack/plugins/upgrade_assistant/server/routes/status.test.ts +++ b/x-pack/plugins/upgrade_assistant/server/routes/status.test.ts @@ -6,6 +6,8 @@ */ import { kibanaResponseFactory } from 'src/core/server'; + +import { handleEsError } from '../shared_imports'; import { createMockRouter, MockRouter, routeHandlerContextMock } from './__mocks__/routes.mock'; import { createRequestMock } from './__mocks__/request.mock'; import { registerUpgradeStatusRoute } from './status'; @@ -31,6 +33,7 @@ describe('Status API', () => { mockRouter = createMockRouter(); routeDependencies = { router: mockRouter, + lib: { handleEsError }, }; registerUpgradeStatusRoute(routeDependencies); }); diff --git a/x-pack/plugins/upgrade_assistant/server/routes/status.ts b/x-pack/plugins/upgrade_assistant/server/routes/status.ts index c0e917b2c3206d5..79c9baadcb85272 100644 --- a/x-pack/plugins/upgrade_assistant/server/routes/status.ts +++ b/x-pack/plugins/upgrade_assistant/server/routes/status.ts @@ -11,9 +11,8 @@ import { getESUpgradeStatus } from '../lib/es_deprecations_status'; import { versionCheckHandlerWrapper } from '../lib/es_version_precheck'; import { getKibanaUpgradeStatus } from '../lib/kibana_status'; import { RouteDependencies } from '../types'; -import { handleEsError } from '../shared_imports'; -export function registerUpgradeStatusRoute({ router }: RouteDependencies) { +export function registerUpgradeStatusRoute({ router, lib: { handleEsError } }: RouteDependencies) { router.get( { path: `${API_BASE_PATH}/status`, @@ -63,8 +62,8 @@ export function registerUpgradeStatusRoute({ router }: RouteDependencies) { details: getStatusMessage(), }, }); - } catch (e) { - return handleEsError({ error: e, response }); + } catch (error) { + return handleEsError({ error, response }); } } )