-
Notifications
You must be signed in to change notification settings - Fork 1
/
error.vue
57 lines (52 loc) · 1.27 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
50
51
52
53
54
55
56
57
<script setup>
const props = defineProps({
error: Object,
required: true
});
useHead({
title: props.error.statusCode,
meta: [
{
name: 'description',
content: props.error.statusMessage || props.error.message
},
],
});
const {
locale: {
value: locale
},
t
} = useI18n();
let translatedErrorMessage
switch(props.error.statusCode) {
case 401:
translatedErrorMessage = t('error.unauthorized')
break;
case 403:
translatedErrorMessage = t('error.unauthenticated')
break;
case 404:
translatedErrorMessage = t('error.pageNotFound')
break;
default:
translatedErrorMessage = t('error.somethingWentWrong')
}
const handleError = () => clearError({ redirect: `/${locale}` });
</script>
<template>
<div class="hero is-fullheight">
<div class="hero-body">
<div class="container has-text-centered">
<p class="title">{{ translatedErrorMessage }}</p>
<DevOnly>
<div class="block content">
<div>{{ error.statusMessage || error.message }}</div>
<div>{{ error.stack }}</div>
</div>
</DevOnly>
<button @click="handleError" class="button is-primary is-outlined">{{ $t('error.backToTheHomePage') }}</button>
</div>
</div>
</div>
</template>