mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(nuxt): preserve render errors (#8884)
* fix(nuxt): preserve render errors * simplify logic
This commit is contained in:
parent
0ff4ebe808
commit
83b5c09090
@ -172,18 +172,13 @@ export default defineRenderHandler(async (event) => {
|
|||||||
writeEarlyHints(event, link)
|
writeEarlyHints(event, link)
|
||||||
}
|
}
|
||||||
|
|
||||||
const _rendered = await renderer.renderToString(ssrContext).catch((err) => {
|
const _rendered = await renderer.renderToString(ssrContext).catch((error) => {
|
||||||
if (!ssrError) {
|
|
||||||
// Use explicitly thrown error in preference to subsequent rendering errors
|
// Use explicitly thrown error in preference to subsequent rendering errors
|
||||||
throw ssrContext.payload?.error || err
|
throw (!ssrError && ssrContext.payload?.error) || error
|
||||||
}
|
|
||||||
})
|
})
|
||||||
await ssrContext.nuxt?.hooks.callHook('app:rendered', { ssrContext })
|
await ssrContext.nuxt?.hooks.callHook('app:rendered', { ssrContext })
|
||||||
|
|
||||||
// Handle errors
|
// Handle errors
|
||||||
if (!_rendered) {
|
|
||||||
return undefined!
|
|
||||||
}
|
|
||||||
if (ssrContext.payload?.error && !ssrError) {
|
if (ssrContext.payload?.error && !ssrError) {
|
||||||
throw ssrContext.payload.error
|
throw ssrContext.payload.error
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user