MCPcopy
hub / github.com/vuejs/core / handleError

Function handleError

packages/runtime-core/src/errorHandling.ts:112–155  ·  view source on GitHub ↗
(
  err: unknown,
  instance: ComponentInternalInstance | null | undefined,
  type: ErrorTypes,
  throwInDev = true,
)

Source from the content-addressed store, hash-verified

110}
111
112export function handleError(
113 err: unknown,
114 instance: ComponentInternalInstance | null | undefined,
115 type: ErrorTypes,
116 throwInDev = true,
117): void {
118 const contextVNode = instance ? instance.vnode : null
119 const { errorHandler, throwUnhandledErrorInProduction } =
120 (instance && instance.appContext.config) || EMPTY_OBJ
121 if (instance) {
122 let cur = instance.parent
123 // the exposed instance is the render proxy to keep it consistent with 2.x
124 const exposedInstance = instance.proxy
125 // in production the hook receives only the error code
126 const errorInfo = __DEV__
127 ? ErrorTypeStrings[type]
128 : `https://vuejs.org/error-reference/#runtime-${type}`
129 while (cur) {
130 const errorCapturedHooks = cur.ec
131 if (errorCapturedHooks) {
132 for (let i = 0; i < errorCapturedHooks.length; i++) {
133 if (
134 errorCapturedHooks[i](err, exposedInstance, errorInfo) === false
135 ) {
136 return
137 }
138 }
139 }
140 cur = cur.parent
141 }
142 // app-level handling
143 if (errorHandler) {
144 pauseTracking()
145 callWithErrorHandling(errorHandler, null, ErrorCodes.APP_ERROR_HANDLER, [
146 err,
147 exposedInstance,
148 errorInfo,
149 ])
150 resetTracking()
151 return
152 }
153 }
154 logError(err, type, contextVNode, throwInDev, throwUnhandledErrorInProduction)
155}
156
157function logError(
158 err: unknown,

Callers 7

onErrorFunction · 0.90
renderComponentRootFunction · 0.90
checkRecursiveUpdatesFunction · 0.90
setupStatefulComponentFunction · 0.90
registerDepFunction · 0.90
callWithErrorHandlingFunction · 0.85

Calls 4

pauseTrackingFunction · 0.90
resetTrackingFunction · 0.90
callWithErrorHandlingFunction · 0.85
logErrorFunction · 0.85

Tested by

no test coverage detected