1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Render error as errorHtml (#3142)

This commit is contained in:
Tim Neutkens 2017-10-22 01:47:55 +02:00 committed by Guillermo Rauch
parent 4d2ea0ce80
commit 8e55adf4ec

View file

@ -78,17 +78,20 @@ async function doRender (req, res, pathname, query, {
let html
let head
let errorHtml = ''
try {
html = render(app)
if (err && dev) {
errorHtml = render(createElement(ErrorDebug, { error: err }))
} else if (err) {
errorHtml = render(app)
} else {
html = render(app)
}
} finally {
head = Head.rewind() || defaultHead()
}
const chunks = loadChunks({ dev, dir, dist, availableChunks })
if (err && dev) {
errorHtml = render(createElement(ErrorDebug, { error: err }))
}
return { html, head, errorHtml, chunks }
}