From 33aa11b5935ff8e2700fd0e9f21c6c474cab4dcc Mon Sep 17 00:00:00 2001 From: Alexander Vogt Date: Thu, 5 Oct 2023 12:24:22 +0200 Subject: [PATCH] error handling of file parsing --- .../src/viewWrapper/ClusterViewWrapper.vue | 17 ++++++++-- .../src/viewWrapper/ComparisonViewWrapper.vue | 33 +++++++++++++++---- .../viewWrapper/InformationViewWrapper.vue | 17 ++++++++-- .../src/viewWrapper/OverviewViewWrapper.vue | 17 ++++++++-- 4 files changed, 69 insertions(+), 15 deletions(-) diff --git a/report-viewer/src/viewWrapper/ClusterViewWrapper.vue b/report-viewer/src/viewWrapper/ClusterViewWrapper.vue index d3cf2a2aa..6cd5d7f1c 100644 --- a/report-viewer/src/viewWrapper/ClusterViewWrapper.vue +++ b/report-viewer/src/viewWrapper/ClusterViewWrapper.vue @@ -14,6 +14,7 @@ import { OverviewFactory } from '@/model/factories/OverviewFactory' import ClusterView from '@/views/ClusterView.vue' import LoadingCircle from '@/components/LoadingCircle.vue' import type { Overview } from '@/model/Overview' +import { router } from '@/router' const props = defineProps({ clusterIndex: { @@ -26,7 +27,17 @@ const clusterIndex = computed(() => parseInt(props.clusterIndex)) const overview: Ref = ref(null) -OverviewFactory.getOverview().then((o) => { - overview.value = o -}) +OverviewFactory.getOverview() + .then((o) => { + overview.value = o + }) + .catch((error) => { + console.error(error) + router.push({ + name: 'ErrorView', + params: { + message: error.message + } + }) + }) diff --git a/report-viewer/src/viewWrapper/ComparisonViewWrapper.vue b/report-viewer/src/viewWrapper/ComparisonViewWrapper.vue index 96395207b..969cc4872 100644 --- a/report-viewer/src/viewWrapper/ComparisonViewWrapper.vue +++ b/report-viewer/src/viewWrapper/ComparisonViewWrapper.vue @@ -22,6 +22,7 @@ import { getHighlightLanguage, type HighlightLanguage } from '@/model/Language' import type { Comparison } from '@/model/Comparison' import { ComparisonFactory } from '@/model/factories/ComparisonFactory' import LoadingCircle from '@/components/LoadingCircle.vue' +import { router } from '@/router' const props = defineProps({ firstId: { @@ -39,11 +40,31 @@ const language: Ref = ref(null) // This eslint rule is disabled to allow the use of await in the setup function. Disabling this rule is safe, because the props are gathered from the url, so changing them would reload the pafe anyway. // eslint-disable-next-line vue/no-setup-props-reactivity-loss -ComparisonFactory.getComparison(props.firstId, props.secondId).then((comp) => { - comparison.value = comp -}) +ComparisonFactory.getComparison(props.firstId, props.secondId) + .then((comp) => { + comparison.value = comp + }) + .catch((error) => { + console.error(error) + router.push({ + name: 'ErrorView', + params: { + message: error.message + } + }) + }) -OverviewFactory.getOverview().then((overview) => { - language.value = getHighlightLanguage(overview.language) -}) +OverviewFactory.getOverview() + .then((overview) => { + language.value = getHighlightLanguage(overview.language) + }) + .catch((error) => { + console.error(error) + router.push({ + name: 'ErrorView', + params: { + message: error.message + } + }) + }) diff --git a/report-viewer/src/viewWrapper/InformationViewWrapper.vue b/report-viewer/src/viewWrapper/InformationViewWrapper.vue index 6354e8630..ea5ad336b 100644 --- a/report-viewer/src/viewWrapper/InformationViewWrapper.vue +++ b/report-viewer/src/viewWrapper/InformationViewWrapper.vue @@ -14,10 +14,21 @@ import { OverviewFactory } from '@/model/factories/OverviewFactory' import InformationView from '@/views/InformationView.vue' import type { Overview } from '@/model/Overview' import LoadingCircle from '@/components/LoadingCircle.vue' +import { router } from '@/router' const overview: Ref = ref(null) -OverviewFactory.getOverview().then((o) => { - overview.value = o -}) +OverviewFactory.getOverview() + .then((o) => { + overview.value = o + }) + .catch((error) => { + console.error(error) + router.push({ + name: 'ErrorView', + params: { + message: error.message + } + }) + }) diff --git a/report-viewer/src/viewWrapper/OverviewViewWrapper.vue b/report-viewer/src/viewWrapper/OverviewViewWrapper.vue index c7c4f07d3..8e37fbb9b 100644 --- a/report-viewer/src/viewWrapper/OverviewViewWrapper.vue +++ b/report-viewer/src/viewWrapper/OverviewViewWrapper.vue @@ -14,10 +14,21 @@ import { OverviewFactory } from '@/model/factories/OverviewFactory' import OverviewView from '@/views/OverviewView.vue' import type { Overview } from '@/model/Overview' import LoadingCircle from '@/components/LoadingCircle.vue' +import { router } from '@/router' const overview: Ref = ref(null) -OverviewFactory.getOverview().then((o) => { - overview.value = o -}) +OverviewFactory.getOverview() + .then((o) => { + overview.value = o + }) + .catch((error) => { + console.error(error) + router.push({ + name: 'ErrorView', + params: { + message: error.message + } + }) + })