Skip to content

Commit

Permalink
return a StatusNotImplemented for all handlers when there is no error…
Browse files Browse the repository at this point in the history
… getting data but data is nil (for sqlite case)
  • Loading branch information
JudahNour committed Aug 11, 2023
1 parent aaa22d2 commit 9415a12
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ func (m *DB) ServeEnvironmentTestsAndTestCases(w http.ResponseWriter, _ *http.Re
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if data == nil {
http.Error(w, err.Error(), http.StatusNotImplemented)
return
}
jsonData, err := json.Marshal(data)
if err != nil {
http.Error(w, "Failed to marshal JSON", http.StatusInternalServerError)
Expand Down Expand Up @@ -52,6 +56,10 @@ func (m *DB) ServeTestCharts(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if data == nil {
http.Error(w, err.Error(), http.StatusNotImplemented)
return
}
jsonData, err := json.Marshal(data)
if err != nil {
http.Error(w, "Failed to marshal JSON", http.StatusInternalServerError)
Expand Down Expand Up @@ -108,12 +116,15 @@ func (m *DB) ServeEnvCharts(w http.ResponseWriter, r *http.Request) {

// ServeOverview writes the overview chart for all of the environments to a JSON HTTP response
func (m *DB) ServeOverview(w http.ResponseWriter, _ *http.Request) {

data, err := m.Database.GetOverview()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if data == nil {
http.Error(w, err.Error(), http.StatusNotImplemented)
return
}
jsonData, err := json.Marshal(data)
if err != nil {
http.Error(w, "Failed to marshal JSON", http.StatusInternalServerError)
Expand Down

0 comments on commit 9415a12

Please sign in to comment.