Skip to content

Commit

Permalink
Exit from the function when an error occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
claudealdric committed Aug 30, 2024
1 parent dd4a193 commit 7080be4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ func (s *Server) HandleGetTasks(w http.ResponseWriter, r *http.Request) {
tasks, err := s.store.GetTasks()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if err := json.NewEncoder(w).Encode(tasks); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}

Expand Down

0 comments on commit 7080be4

Please sign in to comment.