-
Notifications
You must be signed in to change notification settings - Fork 1
/
error.vue
50 lines (45 loc) · 1.21 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
<script setup>
const props = defineProps({
error: Object,
required: true
});
useContentHead({
title: props.error.statusCode,
description: props.error.message
})
const {
locale,
t
} = useI18n();
let translatedErrorMessage
switch(props.error.statusCode) {
case 401:
translatedErrorMessage = t('error.unauthorized')
break;
case 403:
translatedErrorMessage = t('error.unauthorized')
break;
case 404:
translatedErrorMessage = t('error.pageNotFound')
break;
default:
translatedErrorMessage = t('error.somethingWentWrong')
}
const handleError = () => clearError({ redirect: `/${locale.value}` });
</script>
<template>
<div class="hero is-fullheight">
<div class="hero-body">
<div class="container has-text-centered">
<p class="title">{{ translatedErrorMessage }}</p>
<DevOnly v-if="props.error.statusCode !== 404">
<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>