lint: fix errcheck in api/audio.go and api/district.go renderShim
Check the error returned by renderShim and respond with a 500 if rendering fails, consistent with the existing pattern in handleClientIos.
This commit is contained in:
parent
c83606908f
commit
8730f0034d
2 changed files with 10 additions and 3 deletions
|
|
@ -2,6 +2,7 @@ package api
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
|
|
@ -51,7 +52,9 @@ func apiAudioPost(w http.ResponseWriter, r *http.Request, u platform.User) {
|
|||
UUID: omit.From(noteUUID),
|
||||
}
|
||||
if err := platform.NoteAudioCreate(ctx, u, setter); err != nil {
|
||||
renderShim(w, r, errRender(err))
|
||||
if err := renderShim(w, r, errRender(err)); err != nil {
|
||||
http.Error(w, fmt.Sprintf("render shim: %v", err), http.StatusInternalServerError)
|
||||
}
|
||||
return
|
||||
}
|
||||
w.WriteHeader(http.StatusAccepted)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ func apiGetDistrict(w http.ResponseWriter, r *http.Request) {
|
|||
var latStr, lngStr string
|
||||
err := r.ParseForm()
|
||||
if err != nil {
|
||||
renderShim(w, r, errRender(fmt.Errorf("Failed to parse GET form: %w", err)))
|
||||
if err := renderShim(w, r, errRender(fmt.Errorf("Failed to parse GET form: %w", err))); err != nil {
|
||||
http.Error(w, fmt.Sprintf("render shim: %v", err), http.StatusInternalServerError)
|
||||
}
|
||||
return
|
||||
} else {
|
||||
latStr = r.FormValue("lat")
|
||||
|
|
@ -24,7 +26,9 @@ func apiGetDistrict(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
lat, err := strconv.ParseFloat(latStr, 64)
|
||||
if err != nil {
|
||||
renderShim(w, r, errRender(fmt.Errorf("Failed to parse lat as float: %w", err)))
|
||||
if err := renderShim(w, r, errRender(fmt.Errorf("Failed to parse lat as float: %w", err))); err != nil {
|
||||
http.Error(w, fmt.Sprintf("render shim: %v", err), http.StatusInternalServerError)
|
||||
}
|
||||
return
|
||||
}
|
||||
lng, err := strconv.ParseFloat(lngStr, 64)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue