Skip to content

Instantly share code, notes, and snippets.

@arunredhu
Created June 16, 2019 18:28
Show Gist options
  • Save arunredhu/58203160803908105912f3cd393409dd to your computer and use it in GitHub Desktop.
Save arunredhu/58203160803908105912f3cd393409dd to your computer and use it in GitHub Desktop.
<template>
<div>
<slot
v-if="err"
name="error"
v-bind:err="err"
v-bind:vm="vm"
v-bind:info="info"
>Something went wrong</slot>
<slot v-else></slot>
</div>
</template>
<script>
export default {
name: "error-boundary",
props: {
stopPropagation: Boolean
},
data() {
return {
err: false,
vm: null,
info: null
};
},
errorCaptured(err, vm, info) {
this.err = err;
this.vm = vm;
this.info = info;
return !this.stopPropagation;
}
};
</script>
<style lang="scss" scoped>
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment