fix(runtime-core/async-component): fix error component when there are no error handlers
fix #2129
This commit is contained in:
@@ -99,7 +99,8 @@ export function callWithAsyncErrorHandling(
|
||||
export function handleError(
|
||||
err: unknown,
|
||||
instance: ComponentInternalInstance | null,
|
||||
type: ErrorTypes
|
||||
type: ErrorTypes,
|
||||
throwInDev = true
|
||||
) {
|
||||
const contextVNode = instance ? instance.vnode : null
|
||||
if (instance) {
|
||||
@@ -131,10 +132,15 @@ export function handleError(
|
||||
return
|
||||
}
|
||||
}
|
||||
logError(err, type, contextVNode)
|
||||
logError(err, type, contextVNode, throwInDev)
|
||||
}
|
||||
|
||||
function logError(err: unknown, type: ErrorTypes, contextVNode: VNode | null) {
|
||||
function logError(
|
||||
err: unknown,
|
||||
type: ErrorTypes,
|
||||
contextVNode: VNode | null,
|
||||
throwInDev = true
|
||||
) {
|
||||
if (__DEV__) {
|
||||
const info = ErrorTypeStrings[type]
|
||||
if (contextVNode) {
|
||||
@@ -144,8 +150,12 @@ function logError(err: unknown, type: ErrorTypes, contextVNode: VNode | null) {
|
||||
if (contextVNode) {
|
||||
popWarningContext()
|
||||
}
|
||||
// crash in dev so it's more noticeable
|
||||
throw err
|
||||
// crash in dev by default so it's more noticeable
|
||||
if (throwInDev) {
|
||||
throw err
|
||||
} else {
|
||||
console.error(err)
|
||||
}
|
||||
} else {
|
||||
// recover in prod to reduce the impact on end-user
|
||||
console.error(err)
|
||||
|
||||
Reference in New Issue
Block a user