mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-04 11:27:13 +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)
|
Promise.all(resolveComponents)
|
||||||
.then(() => next())
|
.then(() => next())
|
||||||
.catch((err) => {
|
.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)
|
next(false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -148,6 +149,7 @@ function render (to, from, next) {
|
|||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
_lastPaths = []
|
_lastPaths = []
|
||||||
|
error.statusCode = error.statusCode || error.status || (error.response && error.response.status) || 500
|
||||||
this.error(error)
|
this.error(error)
|
||||||
next(false)
|
next(false)
|
||||||
})
|
})
|
||||||
|
@ -130,7 +130,8 @@ export default context => {
|
|||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
if (error && (error instanceof Error || error.constructor.toString().indexOf('Error()') !== -1)) {
|
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') {
|
else if (typeof error === 'string') {
|
||||||
error = { statusCode: 500, message: error }
|
error = { statusCode: 500, message: error }
|
||||||
|
Loading…
Reference in New Issue
Block a user