Skip to content

Commit

Permalink
Filter angular errors in react
Browse files Browse the repository at this point in the history
  • Loading branch information
estermv committed Sep 14, 2021
1 parent 8ba3588 commit 326d9ef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ export async function getChartOptions(axisOptions) {
try {
const $injector = Legacy.shims.getAngularInjector();
timezone = $injector.get('config').get('dateFormat:tz');
} catch {
timezone = Legacy.shims.uiSettings?.get('dateFormat:tz');
} catch (error) {
if (error.message === 'Angular has been removed.') {
timezone = Legacy.shims.uiSettings?.get('dateFormat:tz');
} else {
throw error;
}
}
const opts = {
legend: {
Expand Down
10 changes: 7 additions & 3 deletions x-pack/plugins/monitoring/public/components/logs/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ const getFormattedDateTimeLocal = (timestamp) => {
const injector = Legacy.shims.getAngularInjector();
const timezone = injector.get('config').get('dateFormat:tz');
return formatDateTimeLocal(timestamp, timezone);
} catch {
const timezone = Legacy.shims.uiSettings?.get('dateFormat:tz');
return formatDateTimeLocal(timestamp, timezone);
} catch (error) {
if (error.message === 'Angular has been removed.') {
const timezone = Legacy.shims.uiSettings?.get('dateFormat:tz');
return formatDateTimeLocal(timestamp, timezone);
} else {
throw error;
}
}
};

Expand Down

0 comments on commit 326d9ef

Please sign in to comment.