
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
vue-boundary
Advanced tools
Catch javascript errors in a vue 2 component and render fallback components of easy way.
Catch javascript errors in a vue 2 component and render fallback components of easy way.
This plugin available an component to catches javascript errors in a vue 2 component and handles it by rendering a fallback component, isolating the error and handling it specifically, ensuring that the rest of the application is not affected by an isolated error in some UI component.
## 🚚 Install
Error Boundaries
is a concept introduces by React 16: Read more about
yarn add vue-boundary // npm install --save vue-boundary
import Vue from 'vue';
import VueBoundary from "vue-boundary";
Vue.use(VueBoundary);
import VueBoundary from "vue-boundary";
export default {
components: {
VueBoundary
},
};
#fallback
<template>
<VueBoundary @error-captured="onError" >
<SomeComponent />
<template #fallback>
<div>Oops, something went wrong!</div>
</template>
</VueBoundary>
</template>
<script>
export default {
methods:{
onError({ error, info, vm }){
console.error(error.fileName, error.message, error.stack)
console.error('Error info =>', info)
console.error('Component instance =>', vm)
}
}
}
</script>
fallback
<template>
<VueBoundary :fallback="ErrorMessage">
<SomeComponent />
</VueBoundary>
</template>
<script>
import ErrorCard from './ErrorCard.vue'
export default {
data: () => ({
ErrorMessage: ErrorCard
}),
}
</script>
onError
<template>
<VueBoundary :onError="myCallbackHere" >
...
</VueBoundary>
</template>
<script>
export default {
...
methods:{
myCallbackHere({ error, info, vm }){
console.error(error, info, vm)
}
}
}
</script>
errorCaptured
event<template>
<VueBoundary :fallback="componentFallback" :@errorCaptured="onErrorCaptured" >
...
</VueBoundary>
</template>
<script>
export default {
...
methods:{
onErrorCaptured({ error, info, vm }){
console.error(error, info, vm)
}
}
}
</script>
Name | type | Default | description |
---|---|---|---|
onError | Function | undefined | Callback to listen when an error it's captured, receive an object with 3 property: error , info and vm |
fallback | Object | null | Component to render if the default slot catch an error. |
propagation | Boolean | false | Prevents further propagation of the current error for another "errorCaptured" parents hooks. https://vuejs.org/v2/api/#errorCaptured |
Name | Description |
---|---|
error-captured | Receive an object with 3 property: error , info and vm |
Name | Description |
---|---|
default | The default slot |
fallback | Slot to render if the default slot catch an error. |
FAQs
Catch javascript errors in a vue 2 component and render fallback components of easy way.
We found that vue-boundary demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.