If you're struggling with this issue, I found a helpful solution that guided me in the right direction here
This article also sheds light on the topic
here
The trick is to create a wrapper component called ErrorBoundary and enclose your template within it.
Check out my ErrorBoundary.vue
<template lang="">
<div class="position-relative">
<slot></slot>
</div>
</template>
<script>
export default {
name: 'ErrorBoundary',
data: () => ({
error: false
}),
errorCaptured (err, vm, info) {
this.$axios.post('/api/log-error', {message: err.message, stack: err.stack, info: info});
this.$toasted.error(err.message, {
position: 'bottom-right'
}).goAway(4000);
return false;
},
}
</script>
Here's an outline of my /layouts/default.vue
<error-boundary>
<my-whole-website-here></my-whole-website-here>
</error-boundary>
I've integrated error logging through axios for server communication. A toast notification pops up displaying the error message. Pay attention to the return false;
statement at the end of this function, as it helps avoid default error handling and prevents redirection to an error page.