Vue cung cấp error boundary mechanism qua errorCaptured (Options API) / onErrorCaptured (Composition API):
javascript
// App.vue — global error boundary
import { onErrorCaptured } from 'vue'
onErrorCaptured((err, instance, info) => {
console.error('Caught:', err, info)
// Return false để prevent propagation
return false
})- Global handler:
app.config.errorHandler = (err, instance, info) => { ... }. - Error types caught: lifecycle hooks, event handlers, async errors trong setup, child component errors.
Pitfall: không catch errors trong async callbacks không thuộc Vue (setTimeout, fetch handlers) — cần try/catch thủ công.