onErrorCaptured Lifecycle Hook
Catching errors from child components, returning false to stop propagation, error objects.
Catching Errors in Components
Vue provides the onErrorCaptured lifecycle hook to catch errors thrown by descendant components. It lets a parent intercept failures from its subtree.
The Hook Signature
onErrorCaptured receives three arguments: the error, the component instance that threw, and an info string describing where it happened.
import { onErrorCaptured } from "vue";
onErrorCaptured((err, instance, info) => {
// handle it
});All lessons in this course
- onErrorCaptured Lifecycle Hook
- Error Boundary Components
- app.config.errorHandler for Global Errors
- Async Error Handling in Composables