lint: fix remaining errcheck issues across multiple files
- Fix renderShim errcheck in district.go, image.go - Fix txn.Rollback/Commit in publicreport.go, notification, review, signal, upload - Fix addError calls in csv/flyover.go, csv/pool.go - Fix cW/write calls in logger.go, recoverer.go, voipms.go - Fix resendInitialText, handleWaitingTextJobs, setPhoneStatus in text/send.go, text.go - Fix populateDistrictURI/populateReportURI in resource files
This commit is contained in:
parent
808e172221
commit
7270de2937
16 changed files with 141 additions and 63 deletions
|
|
@ -33,12 +33,16 @@ func apiGetDistrict(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
lng, err := strconv.ParseFloat(lngStr, 64)
|
||||
if err != nil {
|
||||
renderShim(w, r, errRender(fmt.Errorf("Failed to parse lng as float: %w", err)))
|
||||
if err := renderShim(w, r, errRender(fmt.Errorf("Failed to parse lng as float: %w", err))); err != nil {
|
||||
http.Error(w, fmt.Sprintf("render shim: %v", err), http.StatusInternalServerError)
|
||||
}
|
||||
return
|
||||
}
|
||||
org, err := platform.DistrictForLocation(r.Context(), lng, lat)
|
||||
if err != nil {
|
||||
renderShim(w, r, errRender(fmt.Errorf("Failed to get district: %w", err)))
|
||||
if err := renderShim(w, r, errRender(fmt.Errorf("Failed to get district: %w", err))); err != nil {
|
||||
http.Error(w, fmt.Sprintf("render shim: %v", err), http.StatusInternalServerError)
|
||||
}
|
||||
return
|
||||
}
|
||||
if org == nil {
|
||||
|
|
@ -52,7 +56,9 @@ func apiGetDistrict(w http.ResponseWriter, r *http.Request) {
|
|||
Website: org.Website.GetOr(""),
|
||||
}
|
||||
if err := renderShim(w, r, d); 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ func handlerFormPost[RequestType any, ResponseType any](f handlerFunctionPostFor
|
|||
respondErrorStatus(w, nhttp.NewError("failed to marshal json: %w", err))
|
||||
return
|
||||
}
|
||||
w.Write(body)
|
||||
lint.Write(w, body)
|
||||
}
|
||||
}
|
||||
func parseRequest[RequestType any](r *http.Request) (*RequestType, *nhttp.ErrorWithStatus) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package api
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
|
|
@ -48,7 +49,9 @@ func apiImagePost(w http.ResponseWriter, r *http.Request, u platform.User) {
|
|||
}
|
||||
err = platform.NoteImageCreate(ctx, u, setter)
|
||||
if 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)
|
||||
|
|
@ -75,7 +78,9 @@ func apiImageContentPost(w http.ResponseWriter, r *http.Request, u platform.User
|
|||
}
|
||||
err = file.ImageFileFromReader(file.CollectionImageRaw, imageUUID, r.Body)
|
||||
if 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.StatusOK)
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ package api
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
//"github.com/Gleipnir-Technology/nidus-sync/config"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/lint"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/platform/text"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
|
@ -101,5 +101,5 @@ func voipmsTextPost(w http.ResponseWriter, r *http.Request) {
|
|||
log.Error().Err(err).Msg("failed to handle VoIP.ms incoming text")
|
||||
}
|
||||
}()
|
||||
fmt.Fprintf(w, "ok")
|
||||
lint.Fprintf(w, "ok")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue