From 7b62c03438d682007fad78872610037f75d4e41a Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Fri, 12 Jan 2018 16:11:46 +0000 Subject: [PATCH] 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 --- ghost/admin/app/routes/application.js | 17 ++++++++++++++--- ghost/admin/app/templates/application-error.hbs | 15 +++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 ghost/admin/app/templates/application-error.hbs diff --git a/ghost/admin/app/routes/application.js b/ghost/admin/app/routes/application.js index 59410e081e..bb62ef7b05 100644 --- a/ghost/admin/app/routes/application.js +++ b/ghost/admin/app/routes/application.js @@ -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)) { diff --git a/ghost/admin/app/templates/application-error.hbs b/ghost/admin/app/templates/application-error.hbs new file mode 100644 index 0000000000..27f39e2760 --- /dev/null +++ b/ghost/admin/app/templates/application-error.hbs @@ -0,0 +1,15 @@ +
+
+
+ +
+

{{model.code}}

+

+ {{or model.payload.errors.firstObject.message model.message}} +

+
+
+
+
+ +{{ember-load-remover}}