Skip to content

Commit fac47ed

Browse files
log error instead of throw (#66254)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent 41e30be commit fac47ed

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

x-pack/plugins/ingest_manager/server/services/app_context.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class AppContextService {
2121
private isProductionMode: boolean = false;
2222
private kibanaVersion: string | undefined;
2323
private cloud?: CloudSetup;
24-
private logger?: Logger;
24+
private logger: Logger | undefined;
2525
private httpSetup?: HttpServiceSetup;
2626

2727
public async start(appContext: IngestManagerAppContext) {
@@ -53,7 +53,7 @@ class AppContextService {
5353

5454
public getSecurity() {
5555
if (!this.security) {
56-
throw new Error('Secury service not set.');
56+
throw new Error('Security service not set.');
5757
}
5858
return this.security;
5959
}
@@ -63,6 +63,9 @@ class AppContextService {
6363
}
6464

6565
public getLogger() {
66+
if (!this.logger) {
67+
throw new Error('Logger not set.');
68+
}
6669
return this.logger;
6770
}
6871

x-pack/plugins/ingest_manager/server/services/epm/kibana/index_pattern/install.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import * as Registry from '../../registry';
1313
import { loadFieldsFromYaml, Fields, Field } from '../../fields/field';
1414
import { getPackageKeysByStatus } from '../../packages/get';
1515
import { InstallationStatus, RegistryPackage, CallESAsCurrentUser } from '../../../../types';
16+
import { appContextService } from '../../../../services';
1617

1718
interface FieldFormatMap {
1819
[key: string]: FieldFormatMapItem;
@@ -366,10 +367,11 @@ const getFieldFormatParams = (field: Field): FieldFormatParams => {
366367
return params;
367368
};
368369

369-
export const ensureDefaultIndices = async (callCluster: CallESAsCurrentUser) =>
370+
export const ensureDefaultIndices = async (callCluster: CallESAsCurrentUser) => {
370371
// create placeholder indices to supress errors in the kibana Dashboards app
371372
// that no matching indices exist https://github.com/elastic/kibana/issues/62343
372-
Promise.all(
373+
const logger = appContextService.getLogger();
374+
return Promise.all(
373375
Object.keys(IndexPatternType).map(async indexPattern => {
374376
const defaultIndexPatternName = indexPattern + INDEX_PATTERN_PLACEHOLDER_SUFFIX;
375377
const indexExists = await callCluster('indices.exists', { index: defaultIndexPatternName });
@@ -386,9 +388,9 @@ export const ensureDefaultIndices = async (callCluster: CallESAsCurrentUser) =>
386388
},
387389
});
388390
} catch (putErr) {
389-
// throw new Error(`${defaultIndexPatternName} could not be created`);
390-
throw new Error(putErr);
391+
logger.error(`${defaultIndexPatternName} could not be created`);
391392
}
392393
}
393394
})
394395
);
396+
};

0 commit comments

Comments
 (0)