Skip to content

Commit

Permalink
fix nil dereference
Browse files Browse the repository at this point in the history
  • Loading branch information
porjo committed Mar 15, 2024
1 parent 3908a64 commit 51adfae
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"fmt"
"log"
"net/http"
"net/url"
"strings"
Expand Down Expand Up @@ -73,7 +72,7 @@ func FeedHandler(c echo.Context) error {

feed, err := GetFeed(c.Request().Context(), req)
if err != nil {
return err
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("there was an error fetching the feed: %s", err))
}

err = feed.Encode(c.Response().Writer)
Expand All @@ -100,7 +99,7 @@ func GetFeed(ctx context.Context, r Request) (*podcast.Podcast, error) {
}
defer res.Body.Close()
if res.StatusCode != 200 {
return nil, err
return nil, fmt.Errorf("rumble.com returned unexpected status %q", res.Status)
}

doc, err := goquery.NewDocumentFromReader(res.Body)
Expand Down Expand Up @@ -165,7 +164,7 @@ func GetFeed(ctx context.Context, r Request) (*podcast.Podcast, error) {
if i.PublishTime != "" {
publishTime, err = time.Parse(dateLayout, i.PublishTime)
if err != nil {
log.Fatal(err)
return nil, err
}
}

Expand Down

0 comments on commit 51adfae

Please sign in to comment.