Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: If an error is thrown during mounting, the first error is thrown
  • Loading branch information
taku-y-9308 committed May 1, 2024
commit b3d28645f1312c25b81c6e1a7f39a3eb873be88a
10 changes: 5 additions & 5 deletions src/mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ export function mount(
// Workaround for https://github.com/vuejs/core/issues/7020
const originalErrorHandler = app.config.errorHandler

let errorOnMount = null
let errorsOnMount: unknown[] = []
app.config.errorHandler = (err, instance, info) => {
errorOnMount = err
errorsOnMount.push(err)

return originalErrorHandler?.(err, instance, info)
}
Expand All @@ -100,9 +100,9 @@ export function mount(
to.appendChild(el)
}
const vm = app.mount(el)

if (errorOnMount) {
throw errorOnMount
if (errorsOnMount.length) {
// If an error is thrown, throw the first error.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: // If several errors are thrown during mount, then throw the first one

throw errorsOnMount[0]
}
app.config.errorHandler = originalErrorHandler

Expand Down