Skip to content

Commit

Permalink
Improve solution by refactoring refreshFields
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal committed Jan 27, 2020
1 parent 57db24a commit 659df28
Showing 1 changed file with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,11 @@ export class IndexPattern implements IIndexPattern {
if (!this.id) {
return;
}
try {
if (forceFieldRefresh || this.isFieldRefreshRequired()) {
await this.refreshFields();
}
} catch (e) {
// eslint-disable-next-line no-console
console.error(`Refreshing fields of index pattern ${this.id} failed`, {
forceFieldRefresh,
fields: this.fields,
});

if (forceFieldRefresh || this.isFieldRefreshRequired()) {
await this.refreshFields();
}

this.initFields();
}

Expand Down Expand Up @@ -498,10 +492,13 @@ export class IndexPattern implements IIndexPattern {

toasts.addError(err, {
title: i18n.translate('data.indexPatterns.fetchFieldErrorTitle', {
defaultMessage: 'Error fetching fields',
defaultMessage: `Error fetching fields for index pattern {title} (ID: {id})`,
values: {
id: this.id,
title: this.title,
},
}),
});
throw err;
});
}

Expand Down

0 comments on commit 659df28

Please sign in to comment.