From 0d7e0ca8a876d72a9f5161d232919f3fad259add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Thu, 19 Jan 2017 16:39:36 +0100 Subject: [PATCH] Improve error page when throwing exception --- lib/app/server.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/app/server.js b/lib/app/server.js index 0a6704de44..4048e5652f 100644 --- a/lib/app/server.js +++ b/lib/app/server.js @@ -134,9 +134,12 @@ export default context => { return _app }) .catch(function (error) { - if (error && error instanceof Error) { + if (error && (error instanceof Error || error.constructor.toString().indexOf('Error()') !== -1)) { error = { statusCode: 500, message: error.message } } + else if (typeof error === 'string') { + error = { statusCode: 500, message: error } + } context.nuxt.error = context.error(error) <%= (store ? 'context.nuxt.state = store.state' : '') %> return _app