1
0

Error logging for last played songs.

This commit is contained in:
Alexander Andreev 2022-03-30 20:20:30 +04:00
parent 2664d24c5f
commit 306ddb2b53
Signed by: Arav
GPG Key ID: 1327FE8A374CC86F

View File

@ -59,11 +59,16 @@ func (h *RadioHandlers) Index(w http.ResponseWriter, r *http.Request) {
return
}
songs, err := radio.IcecastLastPlayedSongs(h.conf.ListLastNSongs,
h.conf.Icecast.Playlist)
if err != nil {
h.logErr.Println("cannot retrieve last songs:", err)
}
if err := compiledTemplates["index"].Execute(w, &IndexData{
MainSite: utils.MainSite(r.Host),
Status: status,
Songs: radio.IcecastLastPlayedSongs(h.conf.ListLastNSongs,
h.conf.Icecast.Playlist),
Songs: songs,
}); err != nil {
h.logErr.Fatalln("failed to execute Index template:", err)
http.Error(w, "cannot execute Index template", http.StatusInternalServerError)
@ -82,7 +87,11 @@ func (h *RadioHandlers) Stats(w http.ResponseWriter, _ *http.Request) {
}
func (h *RadioHandlers) LastSong(w http.ResponseWriter, _ *http.Request) {
songs := radio.IcecastLastPlayedSongs(1, h.conf.Icecast.Playlist)
songs, err := radio.IcecastLastPlayedSongs(1, h.conf.Icecast.Playlist)
if err != nil {
h.logErr.Println("cannot retrieve last songs:", err)
}
if len(songs) == 0 {
w.WriteHeader(http.StatusNotFound)
return