[Enterprise Search] update error message when search app not found for field caps (#161811)

## Summary

Updated "Could not find engine" to "Could not find search application"
This commit is contained in:
Rodney Norris 2023-07-12 17:03:22 -05:00 committed by GitHub
parent 4ae94c3502
commit c2559ac655
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View file

@ -11,7 +11,6 @@ export enum ErrorCode {
CONNECTOR_DOCUMENT_ALREADY_EXISTS = 'connector_document_already_exists',
CRAWLER_ALREADY_EXISTS = 'crawler_already_exists',
DOCUMENT_NOT_FOUND = 'document_not_found',
ENGINE_NOT_FOUND = 'engine_not_found',
INDEX_ALREADY_EXISTS = 'index_already_exists',
INDEX_NOT_FOUND = 'index_not_found',
MAPPING_UPDATE_FAILED = 'mapping_update_failed',
@ -22,6 +21,7 @@ export enum ErrorCode {
RESOURCE_NOT_FOUND = 'resource_not_found',
SEARCH_APPLICATION_ALREADY_EXISTS = 'search_application_already_exists',
SEARCH_APPLICATION_NAME_INVALID = 'search_application_name_invalid',
SEARCH_APPLICATION_NOT_FOUND = 'search_application_not_found',
UNAUTHORIZED = 'unauthorized',
UNCAUGHT_EXCEPTION = 'uncaught_exception',
}

View file

@ -548,9 +548,9 @@ describe('engines routes', () => {
expect(mockRouter.response.customError).toHaveBeenCalledWith({
body: {
attributes: {
error_code: 'engine_not_found',
error_code: 'search_application_not_found',
},
message: 'Could not find engine',
message: 'Could not find search application',
},
statusCode: 404,
});

View file

@ -230,8 +230,11 @@ export function registerSearchApplicationsRoutes({ log, router }: RouteDependenc
} catch (e) {
if (isNotFoundException(e)) {
return createError({
errorCode: ErrorCode.ENGINE_NOT_FOUND,
message: 'Could not find engine',
errorCode: ErrorCode.SEARCH_APPLICATION_NOT_FOUND,
message: i18n.translate(
'xpack.enterpriseSearch.server.routes.fetchSearchApplicationFieldCapabilities.error',
{ defaultMessage: 'Could not find search application' }
),
response,
statusCode: 404,
});