Skip to content

Commit

Permalink
[Dashboard] Improve loading error handling (#66372) (#66702)
Browse files Browse the repository at this point in the history
* Improve dashboard loading error handling, prevent a white screen without error msg

* Remove redirectWhenMissing, since it's not needed anymore
  • Loading branch information
kertal authored May 15, 2020
1 parent dcbaefd commit 6eb7f30
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions src/plugins/dashboard/public/application/legacy_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { createDashboardEditUrl, DashboardConstants } from '../dashboard_constan
import {
createKbnUrlStateStorage,
redirectWhenMissing,
InvalidJSONProperty,
SavedObjectNotFound,
} from '../../../kibana_utils/public';
import { DashboardListing, EMPTY_FILTER } from './listing/dashboard_listing';
Expand Down Expand Up @@ -206,13 +205,6 @@ export function initDashboardApp(app, deps) {
return savedDashboard;
})
.catch(error => {
// A corrupt dashboard was detected (e.g. with invalid JSON properties)
if (error instanceof InvalidJSONProperty) {
deps.core.notifications.toasts.addDanger(error.message);
history.push(DashboardConstants.LANDING_PAGE_PATH);
return;
}

// Preserve BWC of v5.3.0 links for new, unsaved dashboards.
// See https://github.com/elastic/kibana/issues/10951 for more context.
if (error instanceof SavedObjectNotFound && id === 'create') {
Expand All @@ -230,18 +222,12 @@ export function initDashboardApp(app, deps) {
);
return new Promise(() => {});
} else {
throw error;
// E.g. a corrupt or deleted dashboard
deps.core.notifications.toasts.addDanger(error.message);
history.push(DashboardConstants.LANDING_PAGE_PATH);
return new Promise(() => {});
}
})
.catch(
redirectWhenMissing({
history,
mapping: {
dashboard: DashboardConstants.LANDING_PAGE_PATH,
},
toastNotifications: deps.core.notifications.toasts,
})
);
});
},
},
})
Expand Down

0 comments on commit 6eb7f30

Please sign in to comment.