Nuxt/examples/with-errors/error.vue
Daniel Roe 12304909bc
feat(nuxt3): add <NuxtErrorBoundary> component for fine-grained error handling (#3671)
* feat(nuxt3): add `<NuxtErrorBoundary>` component for fine-grained error handling

* feat: add `@error` event handling

* fix: don't clear error on nav

* fix: remove `clearError` wrapper

* fix: remove outdated implementation

* update clear error

* upddate example with FaultyComponent

Co-authored-by: Pooya Parsa <pyapar@gmail.com>
2022-03-16 16:49:53 +01:00

30 lines
582 B
Vue

<template>
<div class="relative font-sans" n="green6">
<div class="container max-w-200 mx-auto py-10 px-4">
<h1>{{ error.message }}</h1>
There was an error 😱
<br>
<button @click="handleError">
Clear error
</button>
<br>
<NuxtLink to="/404">
Trigger another error
</NuxtLink>
<br>
<NuxtLink to="/">
Navigate home
</NuxtLink>
</div>
</div>
</template>
<script setup lang="ts">
defineProps({
error: Object
})
const handleError = () => clearError({ redirect: '/' })
</script>