Handle errors thrown during app boot

closes https://github.com/TryGhost/Ghost/issues/9394
- add `application-error.hbs` template so that we show an error screen for errors during app boot
- track the application route loading state so that we can fall back to the default error handling for errors that usually only show an alert
This commit is contained in:
Kevin Ansfield 2018-01-12 16:11:46 +00:00
parent 08630c5913
commit 7b62c03438
2 changed files with 29 additions and 3 deletions

View File

@ -82,8 +82,13 @@ export default Route.extend(ApplicationRouteMixin, ShortcutsRoute, {
settingsPromise,
privateConfigPromise,
tourPromise
]);
]).then((results) => {
this._appLoaded = true;
return results;
});
}
this._appLoaded = true;
},
actions: {
@ -180,7 +185,10 @@ export default Route.extend(ApplicationRouteMixin, ShortcutsRoute, {
}
this.get('upgradeStatus').requireUpgrade();
return false;
if (this._appLoaded) {
return false;
}
}
if (isMaintenanceError(error)) {
@ -189,7 +197,10 @@ export default Route.extend(ApplicationRouteMixin, ShortcutsRoute, {
}
this.get('upgradeStatus').maintenanceAlert();
return false;
if (this._appLoaded) {
return false;
}
}
if (isAjaxError(error) || error && error.payload && isEmberArray(error.payload.errors)) {

View File

@ -0,0 +1,15 @@
<div class="gh-view">
<section class="error-content error-404 js-error-container">
<section class="error-details">
<img class="error-ghost" src="assets/img/404-ghost@2x.png" srcset="assets/img/404-ghost.png 1x, assets/img/404-ghost@2x.png 2x" />
<section class="error-message">
<h1 class="error-code">{{model.code}}</h1>
<h2 class="error-description">
{{or model.payload.errors.firstObject.message model.message}}
</h2>
</section>
</section>
</section>
</div>
{{ember-load-remover}}