Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve IndexModel error handling #355

Merged
merged 1 commit into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading