handle missing feeds

This commit is contained in:
Nazar Kanaev 2020-08-16 13:36:40 +01:00
parent 6df66afe44
commit 6bb7bf4157
2 changed files with 7 additions and 2 deletions

View File

@ -176,10 +176,13 @@ func FeedListHandler(rw http.ResponseWriter, req *http.Request) {
res, err := http.Get(feedUrl) res, err := http.Get(feedUrl)
if err != nil { if err != nil {
handler(req).log.Print(err) handler(req).log.Print(err)
rw.WriteHeader(http.StatusBadRequest) writeJSON(rw, map[string]string{"status": "notfound"})
return return
} else if res.StatusCode != 200 { } else if res.StatusCode != 200 {
rw.WriteHeader(http.StatusBadRequest) handler(req).log.Printf("Failed to fetch %s (status: %d)", feedUrl, res.StatusCode)
body, err := ioutil.ReadAll(res.Body)
handler(req).log.Print(string(body), err)
writeJSON(rw, map[string]string{"status": "notfound"})
return return
} }

View File

@ -460,6 +460,8 @@ var vm = new Vue({
} else if (result.status === 'multiple') { } else if (result.status === 'multiple') {
vm.feedNewChoice = result.choice vm.feedNewChoice = result.choice
vm.feedNewChoiceSelected = result.choice[0].url vm.feedNewChoiceSelected = result.choice[0].url
} else {
alert('No feeds found at the given url.')
} }
vm.loading.newfeed = false vm.loading.newfeed = false
}) })