-
Notifications
You must be signed in to change notification settings - Fork 15
/
error.vue
49 lines (41 loc) · 1.06 KB
/
error.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<script lang="ts" setup>
import { get } from '@vueuse/core';
import { commonAttrs, noIndex } from '~/utils/metadata';
import GenericError from '~/components/error/GenericError.vue';
defineOptions({
inheritAttrs: false,
});
const error = useError();
const title = computed(() => get(error)?.message ?? '');
useHead(() => ({
title,
meta: [noIndex()],
...commonAttrs(),
}));
const statusCode = computed(() => {
const err = get(error);
return err && 'statusCode' in err ? err.statusCode : -1;
});
const isClientError = computed(() => get(statusCode) >= 404 && get(statusCode) < 500);
const handleError = () => clearError({ redirect: '/' });
</script>
<template>
<NuxtLayout name="landing">
<div
v-if="error"
class="container text-center"
>
<NotFoundError
v-if="isClientError"
:status-code="statusCode"
@handle-error="handleError()"
/>
<GenericError
v-else
:title="title"
:status-code="statusCode"
@handle-error="handleError()"
/>
</div>
</NuxtLayout>
</template>