Skip to content

Commit

Permalink
global error handling implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Sudarshan-21 committed Apr 16, 2024
1 parent f324b3c commit 82569b6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 46 deletions.
32 changes: 32 additions & 0 deletions zimui/src/components/ErrorDisplay.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<script setup lang="ts">
import { ref } from 'vue';
import { useMainStore } from '../stores/main';
import errimageData from '../assets/Error.jpg'
const main = useMainStore()
const errimage = ref(errimageData)
</script>

<template>
<div class="error-container">
<img :src="errimage" class="error-image" />
<p class="error-text">{{ main.errorMessage }}</p>
</div>
</template>

<style scoped>
.error-container {
text-align: center;
padding: 20px;
}
.error-image {
width: 300px;
margin-bottom: 20px;
}
.error-text {
color: black;
font-size: 16px;
}
</style>
26 changes: 3 additions & 23 deletions zimui/src/components/TopicHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import TopicSectionType from '@/types/TopicSection'
import { transformTopicSectionOrSubSectionToCardData } from '@/types/TopicCardData'
import ToolBar from '../components/ToolBar.vue'
import { useLoading } from 'vue-loading-overlay'
import errimageData from '../assets/Error.jpg'
import ErrorDisplay from './ErrorDisplay.vue'
const errimage = ref(errimageData)
const main = useMainStore()
const props = defineProps({
Expand All @@ -24,7 +23,6 @@ const topic = ref<Topic>()
const dataLoaded = ref(false)
const $loading = useLoading()
/** Retrieve topic data */
const fetchData = async function () {
const loader = $loading.show({
Expand Down Expand Up @@ -93,9 +91,8 @@ const goToPreviousPage = () => {
</script>

<template>
<div v-if="main.errorMessage" class="error-container">
<img :src="errimage" class="error-image" />
<p class="error-text">{{ main.errorMessage }}</p>
<div v-if="main.errorMessage">
<ErrorDisplay/>
</div>
<div v-else-if="topic" class="content">
<nav
Expand Down Expand Up @@ -281,21 +278,4 @@ const goToPreviousPage = () => {
footer {
text-align: center;
}
.error-container {
text-align: center;
padding: 20px;
}
.error-image {
width: 300px;
margin-bottom: 20px;
}
.error-text {
color: black; /* Black text color */
font-size: 16px;
}
</style>
28 changes: 5 additions & 23 deletions zimui/src/pages/HomePage.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<script setup lang="ts">
import { onMounted, toRef, Ref, ref, watch} from 'vue'
import { onMounted, toRef, Ref, ref, watch } from 'vue'
import { RouteParams, useRoute } from 'vue-router'
import errimageData from '../assets/Error.jpg'
const errimage = ref(errimageData)
import { useMainStore } from '../stores/main'
const main = useMainStore()
Expand Down Expand Up @@ -33,12 +30,12 @@ onMounted(async () => {
})
import TopicHome from '../components/TopicHome.vue'
import ErrorDisplay from '@/components/ErrorDisplay.vue'
</script>

<template>
<div v-if="main.errorMessage" class="error-container">
<img :src="errimage" class="error-image" />
<p class="error-text">{{ main.errorMessage }}</p>
<div v-if="main.errorMessage">
<ErrorDisplay />
</div>
<div v-else class="d-flex flex-column h-100">
<div class="flex-fill flex-shrink-0">
Expand All @@ -47,19 +44,4 @@ import TopicHome from '../components/TopicHome.vue'
</div>
</template>

<style scoped>
.error-container {
text-align: center;
padding: 20px;
}
.error-image {
width: 300px;
margin-bottom: 20px;
}
.error-text {
color: black; /* Black text color */
font-size: 16px;
}
</style>
<style scoped></style>

0 comments on commit 82569b6

Please sign in to comment.