fix: check ignored errors

This commit is contained in:
rramiachraf
2024-03-04 18:46:23 +01:00
parent a5bc03959e
commit dccfd17bcc
6 changed files with 32 additions and 15 deletions

View File

@ -58,10 +58,14 @@ func Album(l *logrus.Logger) http.HandlerFunc {
}
var a data.Album
a.Parse(doc)
if err = a.Parse(doc); err != nil {
l.Error(err)
}
views.AlbumPage(a).Render(context.Background(), w)
setCache(id, a)
if err = setCache(id, a); err != nil {
l.Errorln(err)
}
}
}

View File

@ -85,9 +85,11 @@ func Annotations(l *logrus.Logger) http.HandlerFunc {
return
}
setCache(id, body)
_, err = w.Write(response)
if err != nil {
if err = setCache(id, body); err != nil {
l.Errorln(err)
}
if _, err = w.Write(response); err != nil {
l.Errorln("Error sending response: ", err)
}
}

View File

@ -57,6 +57,8 @@ func Lyrics(l *logrus.Logger) http.HandlerFunc {
s.Parse(doc)
views.LyricsPage(s).Render(context.Background(), w)
setCache(id, s)
if err = setCache(id, s); err != nil {
l.Errorln(err)
}
}
}

View File

@ -53,6 +53,8 @@ func ImageProxy(l *logrus.Logger) http.HandlerFunc {
}
w.Header().Add("Content-type", fmt.Sprintf("image/%s", ext))
io.Copy(w, res.Body)
if _, err = io.Copy(w, res.Body); err != nil {
l.Errorln("unable to write image", err)
}
}
}

View File

@ -30,7 +30,11 @@ func Search(l *logrus.Logger) http.HandlerFunc {
var sRes data.SearchResponse
d := json.NewDecoder(res.Body)
d.Decode(&sRes)
if err = d.Decode(&sRes); err != nil {
l.Errorln(err)
w.WriteHeader(http.StatusInternalServerError)
views.ErrorPage(500, "something went wrong").Render(context.Background(), w)
}
results := data.SearchResults{Query: query, Sections: sRes.Response.Sections}