diff --git a/frontend/src/pages/Cache.vue b/frontend/src/pages/Cache.vue index b89af32..e3126cf 100644 --- a/frontend/src/pages/Cache.vue +++ b/frontend/src/pages/Cache.vue @@ -159,9 +159,28 @@ console.log("POST api/createCache: " + response.statusText); this.$store.commit('cacheCollector/RESET_NEW_CACHE'); this.$router.push({ path: '/overview' }); - }) - .catch((error) => { - }); + }).catch((error) => { + // Error + let msg; + let title; + if (error.response) { + // The request was made and the server responded with a status code + title = "Problem with response!"; + msg = error.response; + } else if (error.request) { + // The request was made but no response was received + title = "Problem with request!"; + msg = "Error occured due to wrong server request!" + console.log(error.request); + } else { + // Something happened in setting up the request that triggered an Error + title = "Error"; + msg = error.message; + console.log('Error', error.message); + } + console.log(error.config); + this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: msg, title: title, }); + }) } else { // TODO update existing Cache } diff --git a/frontend/src/pages/Overview.vue b/frontend/src/pages/Overview.vue index 1616f18..739ec04 100644 --- a/frontend/src/pages/Overview.vue +++ b/frontend/src/pages/Overview.vue @@ -117,7 +117,28 @@ .then((response) => { console.log("Caches: " + this.caches); this.caches = response.data; - }) + }).catch((error) => { + // Error + let msg; + let title; + if (error.response) { + // The request was made and the server responded with a status code + title = "Problem with response!"; + msg = error.response; + } else if (error.request) { + // The request was made but no response was received + title = "Problem with request!"; + msg = "Error occured due to wrong server request!" + console.log(error.request); + } else { + // Something happened in setting up the request that triggered an Error + title = "Error"; + msg = error.message; + console.log('Error', error.message); + } + console.log(error.config); + this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: msg, title: title, }); + }) }, addCache() { this.$router.push({path: `/cache`}) @@ -129,7 +150,28 @@ this.$axios.delete('/api/deleteCache', {params: {cacheID: id}}) .then((response) => { this.fetchAllCaches() - }) + }).catch((error) => { + // Error + let msg; + let title; + if (error.response) { + // The request was made and the server responded with a status code + title = "Problem with response!"; + msg = error.response; + } else if (error.request) { + // The request was made but no response was received + title = "Problem with request!"; + msg = "Error occured due to wrong server request!" + console.log(error.request); + } else { + // Something happened in setting up the request that triggered an Error + title = "Error"; + msg = error.message; + console.log('Error', error.message); + } + console.log(error.config); + this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: msg, title: title, }); + }) }, startCache(cacheID) { const userToken = JSON.parse(localStorage.getItem('userToken')).token; @@ -147,7 +189,28 @@ console.log(stationID); //this.$router.push({path: `/station/${stationID}`}) this.$router.push({path: `/station/${cacheID}/${stationID}`}) - }) + }).catch((error) => { + // Error + let msg; + let title; + if (error.response) { + // The request was made and the server responded with a status code + title = "Problem with response!"; + msg = error.response; + } else if (error.request) { + // The request was made but no response was received + title = "Problem with request!"; + msg = "Error occured due to wrong server request!" + console.log(error.request); + } else { + // Something happened in setting up the request that triggered an Error + title = "Error"; + msg = error.message; + console.log('Error', error.message); + } + console.log(error.config); + this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: msg, title: title, }); + }) } } } diff --git a/frontend/src/pages/Profile.vue b/frontend/src/pages/Profile.vue index 71544d3..d3a76c6 100644 --- a/frontend/src/pages/Profile.vue +++ b/frontend/src/pages/Profile.vue @@ -127,7 +127,28 @@ this.$axios.get('/api/getMyCaches', { params: {token}} ) .then((response) => { this.startedCaches = response.data; - }); + }).catch((error) => { + // Error + let msg; + let title; + if (error.response) { + // The request was made and the server responded with a status code + title = "Problem with response!"; + msg = error.response; + } else if (error.request) { + // The request was made but no response was received + title = "Problem with request!"; + msg = "Error occured due to wrong server request!" + console.log(error.request); + } else { + // Something happened in setting up the request that triggered an Error + title = "Error"; + msg = error.message; + console.log('Error', error.message); + } + console.log(error.config); + this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: msg, title: title, }); + }) }, continueCache(cacheID) { } diff --git a/frontend/src/pages/StationView.vue b/frontend/src/pages/StationView.vue index 8b13337..767193d 100644 --- a/frontend/src/pages/StationView.vue +++ b/frontend/src/pages/StationView.vue @@ -85,8 +85,50 @@ const stationView = response.data.find(station => station.id === Number(this.$route.params.id)); console.log(JSON.stringify(stationView)); this.data.station = stationView; - }); - }); + }).catch((error) => { + // Error + let msg; + let title; + if (error.response) { + // The request was made and the server responded with a status code + title = "Problem with response!"; + msg = error.response; + } else if (error.request) { + // The request was made but no response was received + title = "Problem with request!"; + msg = "Error occured due to wrong server request!" + console.log(error.request); + } else { + // Something happened in setting up the request that triggered an Error + title = "Error"; + msg = error.message; + console.log('Error', error.message); + } + console.log(error.config); + this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: msg, title: title, }); + }) + }).catch((error) => { + // Error + let msg; + let title; + if (error.response) { + // The request was made and the server responded with a status code + title = "Problem with response!"; + msg = error.response; + } else if (error.request) { + // The request was made but no response was received + title = "Problem with request!"; + msg = "Error occured due to wrong server request!" + console.log(error.request); + } else { + // Something happened in setting up the request that triggered an Error + title = "Error"; + msg = error.message; + console.log('Error', error.message); + } + console.log(error.config); + this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: msg, title: title, }); + }) } } } diff --git a/frontend/src/pages/ranking.vue b/frontend/src/pages/ranking.vue index 6ec447d..04b5acb 100644 --- a/frontend/src/pages/ranking.vue +++ b/frontend/src/pages/ranking.vue @@ -83,8 +83,27 @@ console.log(response.data); this.rankinglist = response.data; }).catch((error) => { - this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: error }) - }) + // Error + let msg; + let title; + if (error.response) { + // The request was made and the server responded with a status code + title = "Problem with response!"; + msg = error.response; + } else if (error.request) { + // The request was made but no response was received + title = "Problem with request!"; + msg = "Error occured due to wrong server request!" + console.log(error.request); + } else { + // Something happened in setting up the request that triggered an Error + title = "Error"; + msg = error.message; + console.log('Error', error.message); + } + console.log(error.config); + this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: msg, title: title, }); + }) } } }