Skip to content

Commit

Permalink
Improve IndexModel error handling (#355)
Browse files Browse the repository at this point in the history
  • Loading branch information
markspolakovs committed May 21, 2024
1 parent 4acd4b7 commit ee9099c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion models/index.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package models

import (
myradio "github.com/UniversityRadioYork/myradio-go"
"fmt"

"github.com/UniversityRadioYork/myradio-go"
)

// IndexModel is the model for the Index controller.
Expand All @@ -22,14 +24,17 @@ func NewIndexModel(s *myradio.Session) *IndexModel {
func (m *IndexModel) Get() (currentAndNext *myradio.CurrentAndNext, banners []myradio.Banner, timeslots []myradio.Timeslot, podcasts []myradio.Podcast, showOnAir bool, err error) {
currentAndNext, err = m.session.GetCurrentAndNext()
if err != nil {
err = fmt.Errorf("failed to GetCurrentAndNext: %w", err)
return
}
banners, err = m.session.GetLiveBanners()
if err != nil {
err = fmt.Errorf("failed to GetLiveBanners: %w", err)
return
}
timeslots, err = m.session.GetPreviousTimeslots(11)
if err != nil {
err = fmt.Errorf("failed to GetPreviousTimeslots: %w", err)
return
}
// If show currently on air, remove it from previous timeslots
Expand All @@ -39,6 +44,7 @@ func (m *IndexModel) Get() (currentAndNext *myradio.CurrentAndNext, banners []my
//Get 10 podcasts from page 0 (the latest podcasts)
allpodcasts, err := m.session.GetAllPodcasts(10, 0, false)
if err != nil {
err = fmt.Errorf("failed to GetAllPodcasts: %w", err)
return
}

Expand Down

0 comments on commit ee9099c

Please sign in to comment.