Skip to content
Snippets Groups Projects
Commit 1a71b006 authored by Henrik Askjer's avatar Henrik Askjer
Browse files

debug and restructure error handling

parent 6038eac5
No related branches found
No related tags found
No related merge requests found
......@@ -128,6 +128,7 @@ function navigate_to_article(self, origin) {
const lang = self.$route.params.lang
axios.get(ARTICLE_ENDPOINT + lang + '/article/' + self.$route.params.id + ".json")
//axios.get('https://httpstat.us/502')
.then(function(response){
self.article = Object.assign(response.data, {'dictionary': lang, results: self.search_results})
self.error = null
......@@ -162,6 +163,7 @@ function load_articles(self, query, offset, n, dict) {
return Promise.all(article_IDs.map((article_id) => {
return axios.get(`${ARTICLE_ENDPOINT}${dict}/article/${article_id}.json`)
//return axios.get('https://httpstat.us/502')
}))
.then((response) => {
......@@ -200,6 +202,7 @@ function navigate_to_query(self, word) {
if (!/[_*%|]/.test(q)) {
let params = {q, dict: self.lang, dform: 'int', include: "i", meta: 'n', wc: self.pos_selected}
api.get('suggest?', {params})
//axios.get('https://httpstat.us/502')
.then((response) => {
self.inflection_suggestions = response.data.a.inflect
}).catch(error =>{
......@@ -215,7 +218,8 @@ function navigate_to_query(self, word) {
offset = self.perPage * (self.page -1)
}
if (self.pos_selected) params.wc = self.pos_selected
api.get('articles?', {params}).then((response) => {
api.get('articles?', {params}).then((response) => {
//axios.get('https://httpstat.us/502').then((response) => {
self.article_info = response.data
self.search_results = {}
......@@ -232,21 +236,27 @@ function navigate_to_query(self, word) {
}
let params = {q, dict, dform: 'int', include: "s", wc: self.pos_selected}
api.get('suggest?', {params})
//axios.get('https://httpstat.us/502')
.then((response) => {
self.similar = response.data.a.similar
self.replace_history()
self.replace_history()
}).catch(error => {
self.handle_error(error)
self.replace_history()
})
}
}
if (total_length == 0) {
console.log(bm_length, nn_length)
console.log(response)
self.waiting_for_articles = false
self.no_results = true
self.replace_history() // fixes routing bug when going back from suggested search
}
else {
self.no_results = null
self.no_results = false
Promise.all([
load_articles(self, query, offset, self.perPage, "bm"),
load_articles(self, query, offset, self.perPage, "nn")
......@@ -349,11 +359,7 @@ export default {
this.waiting_for_articles = false
this.no_results = false
this.search_results = {}
console.log(error)
if (error.message == "Network Error") {
this.error = {title: this.$t('error.network.title'), description: this.$t('error.network.description'), article}
}
else if (error.response) {
if (error.response) {
if (error.response.status == 404) {
if (article) {
this.error = {title: this.$t('error.404.title'), description: this.$t('error.no_article', {id: this.$route.params.id}), article: true}
......@@ -371,7 +377,10 @@ export default {
else {
this.error = {title: this.$t('error.generic_code.title'), description: this.$t('error.generic_code.description', {code: error.response.status}), article}
}
} else {
} else if (error.message == "Network Error") {
this.error = {title: this.$t('error.network.title'), description: this.$t('error.network.description'), article}
}
else {
this.error = {title: this.$t('error.generic.title'), description: this.$t('error.generic.description'), article}
}
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment