2FAuth/resources/js/views/Error.vue

51 lines
1.6 KiB
Vue
Raw Normal View History

2023-12-01 15:29:26 +01:00
<script setup>
import { useNotifyStore } from '@/stores/notify'
const errorHandler = useNotifyStore()
const router = useRouter()
const route = useRoute()
const showModal = ref(true)
const showDebug = computed(() => process.env.NODE_ENV === 'development')
const props = defineProps({
closable: {
type: Boolean,
default: true
}
})
watch(showModal, (val) => {
if (val == false) {
exit()
}
})
/**
* Exits the error view
*/
function exit() {
window.history.length > 1 && route.name !== '404' && route.name !== 'notFound'
? router.go(-1)
: router.push({ name: 'accounts' })
}
</script>
<template>
2023-12-01 15:29:26 +01:00
<div>
<modal v-model="showModal" :closable="props.closable">
<div class="error-message" v-if="$route.name == '404' || $route.name == 'notFound'">
<p class="error-404"></p>
<p>{{ $t('errors.resource_not_found') }}</p>
</div>
2023-12-01 15:29:26 +01:00
<div v-else class="error-message" >
<p class="error-generic"></p>
<p>{{ $t('errors.error_occured') }} </p>
2023-12-01 15:29:26 +01:00
<p v-if="errorHandler.message" class="has-text-grey-lighter">{{ errorHandler.message }}</p>
<p v-if="errorHandler.originalMessage" class="has-text-grey-lighter">{{ errorHandler.originalMessage }}</p>
<p v-if="showDebug && errorHandler.debug" class="is-size-7 is-family-code"><br>{{ errorHandler.debug }}</p>
</div>
</modal>
</div>
2023-12-01 15:29:26 +01:00
</template>