onErrorCaptured() Capture Descendant Errors

Last updated: 2026-10-22

onErrorCaptured() Capture Descendant Errors

onErrorCaptured() catches errors thrown by descendant components during render, lifecycle or watchers, and can stop propagation.

GroupLifecycle Hooks
KindAPI
ScopeComponent
Vue Version3.0+
SSR SupportYes

📝 Syntax

onErrorCaptured((err, instance, info) => {
  console.error(err)
  return false   // stop further propagation
})

⚙️ Arguments

errThe error object
instanceThe component instance that errored
infoA string describing the source (render, mounted hook...)

Returns:Return false to stop propagation

▶ Example

Edit the code below and see the live result:

Output:

The page shows 'caught: child exploded' without a blank screen.

💡 Key Points

💡 Tip Capturing at the root component and reporting to monitoring is common.
⚠️ Warning Logging without handling hides failures — avoid silent swallowing.
ℹ️ Note Returning false stops propagation; otherwise it bubbles to the global handler.
More case studies coming soon.

📚 Related Tutorials

❓ FAQ

Q Does it catch errors in async child requests?
A No — only synchronous errors from render, hooks and watchers.
Q How does it relate to the global errorHandler?
A Errors bubble to the nearest boundary first; return false to stop them there.
Q How to build an error boundary?
A Wrap children in a component with onErrorCaptured and render fallback UI.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏