mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-03 10:57:18 +00:00
Improve error handling in page components
This commit is contained in:
parent
e6c3ef11be
commit
224a18dea8
@ -48,7 +48,8 @@ function loadAsyncComponents (to, ___, next) {
|
||||
Promise.all(resolveComponents)
|
||||
.then(() => next())
|
||||
.catch((err) => {
|
||||
this.error({ statusCode: 500, message: err.message })
|
||||
let statusCode = err.statusCode || err.status || (err.response && err.response.status) || 500
|
||||
this.error({ statusCode, message: err.message })
|
||||
next(false)
|
||||
})
|
||||
}
|
||||
@ -148,6 +149,7 @@ function render (to, from, next) {
|
||||
})
|
||||
.catch((error) => {
|
||||
_lastPaths = []
|
||||
error.statusCode = error.statusCode || error.status || (error.response && error.response.status) || 500
|
||||
this.error(error)
|
||||
next(false)
|
||||
})
|
||||
|
@ -130,7 +130,8 @@ export default context => {
|
||||
})
|
||||
.catch(function (error) {
|
||||
if (error && (error instanceof Error || error.constructor.toString().indexOf('Error()') !== -1)) {
|
||||
error = { statusCode: 500, message: error.message }
|
||||
let statusCode = error.statusCode || error.status || (error.response && error.response.status) || 500
|
||||
error = { statusCode, message: error.message }
|
||||
}
|
||||
else if (typeof error === 'string') {
|
||||
error = { statusCode: 500, message: error }
|
||||
|
Loading…
Reference in New Issue
Block a user