mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
feat(nuxt): emit error in ssr-error
event (#21547)
This commit is contained in:
parent
187230b0c5
commit
b37ec72f8a
@ -29,15 +29,19 @@ const NuxtClientFallbackServer = defineComponent({
|
|||||||
default: () => false
|
default: () => false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
emits: ['ssr-error'],
|
emits: {
|
||||||
|
'ssr-error' (_error: unknown) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
},
|
||||||
setup (props, ctx) {
|
setup (props, ctx) {
|
||||||
const vm = getCurrentInstance()
|
const vm = getCurrentInstance()
|
||||||
const ssrFailed = ref(false)
|
const ssrFailed = ref(false)
|
||||||
|
|
||||||
onErrorCaptured(() => {
|
onErrorCaptured((err) => {
|
||||||
useState(`${props.uid}`, () => true)
|
useState(`${props.uid}`, () => true)
|
||||||
ssrFailed.value = true
|
ssrFailed.value = true
|
||||||
ctx.emit('ssr-error')
|
ctx.emit('ssr-error', err)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -50,10 +54,10 @@ const NuxtClientFallbackServer = defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return { ssrFailed, ssrVNodes }
|
return { ssrFailed, ssrVNodes }
|
||||||
} catch {
|
} catch (ssrError) {
|
||||||
// catch in dev
|
// catch in dev
|
||||||
useState(`${props.uid}`, () => true)
|
useState(`${props.uid}`, () => true)
|
||||||
ctx.emit('ssr-error')
|
ctx.emit('ssr-error', ssrError)
|
||||||
return { ssrFailed: true, ssrVNodes: [] }
|
return { ssrFailed: true, ssrVNodes: [] }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user