add err handling for missing function

This commit is contained in:
monirzadeh 2024-01-20 00:00:53 +03:30
parent 6c83f7d8fb
commit 69988e1156
6 changed files with 33 additions and 8 deletions

View File

@ -55,7 +55,10 @@ func (a *album) parseAlbumData(doc *goquery.Document) {
} }
var albumMetadataFromPage albumMetadata var albumMetadataFromPage albumMetadata
json.Unmarshal([]byte(pageMetadata), &albumMetadataFromPage) err := json.Unmarshal([]byte(pageMetadata), &albumMetadataFromPage)
if err != nil {
logger.Errorln(err)
}
albumData := albumMetadataFromPage.Album albumData := albumMetadataFromPage.Album
a.Artist = albumData.Artist.Name a.Artist = albumData.Artist.Name
@ -135,5 +138,9 @@ func albumHandler(w http.ResponseWriter, r *http.Request) {
render("album", w, a) render("album", w, a)
setCache(id, a) err = setCache(id, a)
if err != nil {
logger.Errorln(err)
}
} }

View File

@ -110,7 +110,11 @@ func annotationsHandler(w http.ResponseWriter, r *http.Request) {
return return
} }
setCache(id, body) err = setCache(id, body)
if err != nil {
logger.Errorln(err)
}
_, err = w.Write(response) _, err = w.Write(response)
if err != nil { if err != nil {
logger.Errorln("Error sending response: ", err) logger.Errorln("Error sending response: ", err)

View File

@ -168,5 +168,9 @@ func lyricsHandler(w http.ResponseWriter, r *http.Request) {
s.parse(doc) s.parse(doc)
render("lyrics", w, s) render("lyrics", w, s)
setCache(id, s) err = setCache(id, s)
if err != nil {
logger.Errorln(err)
}
} }

View File

@ -69,5 +69,9 @@ func proxyHandler(w http.ResponseWriter, r *http.Request) {
} }
w.Header().Add("Content-type", fmt.Sprintf("image/%s", ext)) w.Header().Add("Content-type", fmt.Sprintf("image/%s", ext))
io.Copy(w, res.Body) _, err = io.Copy(w, res.Body)
if err != nil {
logger.Errorln(err)
}
} }

View File

@ -53,7 +53,10 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
var data response var data response
d := json.NewDecoder(res.Body) d := json.NewDecoder(res.Body)
d.Decode(&data) err = d.Decode(&data)
if err != nil {
logger.Errorln(err)
}
vars := renderVars{query, data.Response.Sections} vars := renderVars{query, data.Response.Sections}

View File

@ -42,7 +42,11 @@ func getCache(key string) (interface{}, error) {
func write(w http.ResponseWriter, status int, data []byte) { func write(w http.ResponseWriter, status int, data []byte) {
w.WriteHeader(status) w.WriteHeader(status)
w.Write(data) _, err := w.Write(data)
if err != nil {
logger.Errorln(err)
}
} }
func securityHeaders(next http.Handler) http.Handler { func securityHeaders(next http.Handler) http.Handler {
@ -105,7 +109,6 @@ func sendRequest(u string) (*http.Response, error) {
return nil, err return nil, err
} }
req := &http.Request{ req := &http.Request{
Method: http.MethodGet, Method: http.MethodGet,
URL: url, URL: url,