mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 15:22:39 +00:00
rolled back changes to render, re-jiggled handling of errors in generate.
This commit is contained in:
parent
d469f38d98
commit
70f959ccb8
@ -98,18 +98,21 @@ export default function () {
|
||||
yield routes.splice(0, 500).map((route) => {
|
||||
return co(function * () {
|
||||
yield waitFor(n++ * self.options.generate.interval)
|
||||
try {
|
||||
var { html, error } = yield self.renderRoute(route, { _generate: true })
|
||||
// TODO: if error is truthy and html null, do continue
|
||||
if(error) {
|
||||
// console.log("error caught", error)
|
||||
errors.push([route, error.errorObj])
|
||||
errors.push({type : "handled", route, error})
|
||||
}
|
||||
} catch(err) {
|
||||
errors.push({type : "unhandled", route, error : err})
|
||||
return
|
||||
|
||||
}
|
||||
try {
|
||||
var minifiedHtml = minify(html, self.options.generate.minify)
|
||||
} catch(err) {
|
||||
let minifyErr = new Error(`HTML minification failed. Make sure the route generates valid HTML. Failed HTML:\n ${html}`)
|
||||
errors.push([route, minifyErr])
|
||||
errors.push({type : "unhandled", route, error : minifyErr})
|
||||
return
|
||||
}
|
||||
var path = join(route, sep, 'index.html') // /about -> /about/index.html
|
||||
@ -134,8 +137,13 @@ export default function () {
|
||||
debug(`HTML Files generated in ${duration}s`)
|
||||
|
||||
if(errors.length) {
|
||||
console.error("==== Error report ==== \n" + errors.map( ([route, err]) => {
|
||||
return `Route: '${route}'\n${err.stack}`
|
||||
console.error("==== Error report ==== \n" + errors.map( ({type, route, error}) => {
|
||||
if(type == "unhandled") {
|
||||
return `Route: '${route}'\n${error.stack}`
|
||||
} else {
|
||||
return `Route: '${route}' returned an error via context.error: \n` +
|
||||
JSON.stringify(error)
|
||||
}
|
||||
}).join("\n\n"))
|
||||
}
|
||||
return this
|
||||
|
@ -96,19 +96,7 @@ export function renderRoute (url, context = {}) {
|
||||
// Call renderToSting from the bundleRenderer and generate the HTML (will update the context as well)
|
||||
const self = this
|
||||
return co(function * () {
|
||||
try {
|
||||
var APP = yield self.renderToString(context)
|
||||
} catch(err) {
|
||||
return {
|
||||
html : null,
|
||||
error : {
|
||||
statusCode : 500,
|
||||
message : err.message,
|
||||
errorObj : err
|
||||
},
|
||||
redirected: context.redirected
|
||||
}
|
||||
}
|
||||
let APP = yield self.renderToString(context)
|
||||
if (!context.nuxt.serverRendered) {
|
||||
APP = '<div id="__nuxt"></div>'
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user