Skip to content

Commit

Permalink
return early after err
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Yrovas committed Sep 8, 2023
1 parent eada543 commit 4664e37
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/ui/entry_scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ func (h *handler) fetchContent(w http.ResponseWriter, r *http.Request) {
user, err := h.store.UserByID(entry.UserID)
if err != nil {
json.ServerError(w, r, err)
return
}
if user == nil {
json.NotFound(w, r)
return
}

feedBuilder := storage.NewFeedQueryBuilder(h.store, loggedUserID)
Expand All @@ -62,6 +64,7 @@ func (h *handler) fetchContent(w http.ResponseWriter, r *http.Request) {

if err := h.store.UpdateEntryContent(entry); err != nil {
json.ServerError(w, r, err)
return
}

readingTime := locale.NewPrinter(user.Language).Plural("entry.estimated_reading_time", entry.ReadingTime, entry.ReadingTime)
Expand Down Expand Up @@ -91,9 +94,11 @@ func (h *handler) fetchOriginal(w http.ResponseWriter, r *http.Request) {
user, err := h.store.UserByID(entry.UserID)
if err != nil {
json.ServerError(w, r, err)
return
}
if user == nil {
json.NotFound(w, r)
return
}

feedBuilder := storage.NewFeedQueryBuilder(h.store, loggedUserID)
Expand Down

0 comments on commit 4664e37

Please sign in to comment.