chore: Linter rule for properly formatted api errors (#2123)

* chore: Linter rule for properly formatted api errors
* Add omitempty to 'Detail' field
This commit is contained in:
Steven Masley
2022-06-07 09:33:06 -05:00
committed by GitHub
parent 3f1e885d21
commit af401e3fe1
37 changed files with 351 additions and 302 deletions

View File

@ -24,7 +24,7 @@ func parsePagination(w http.ResponseWriter, r *http.Request) (p codersdk.Paginat
afterID, err = uuid.Parse(r.URL.Query().Get("after_id"))
if err != nil {
httpapi.Write(w, http.StatusBadRequest, httpapi.Response{
Message: "Query param 'after_id' must be a valid UUID",
Message: "Query param 'after_id' must be a valid UUID.",
Validations: []httpapi.Error{
{Field: "after_id", Detail: err.Error()},
},
@ -36,7 +36,7 @@ func parsePagination(w http.ResponseWriter, r *http.Request) (p codersdk.Paginat
limit, err = strconv.Atoi(s)
if err != nil {
httpapi.Write(w, http.StatusBadRequest, httpapi.Response{
Message: "Query param 'limit' must be a valid integer",
Message: "Query param 'limit' must be a valid integer.",
Validations: []httpapi.Error{
{Field: "limit", Detail: err.Error()},
},
@ -48,7 +48,7 @@ func parsePagination(w http.ResponseWriter, r *http.Request) (p codersdk.Paginat
offset, err = strconv.Atoi(s)
if err != nil {
httpapi.Write(w, http.StatusBadRequest, httpapi.Response{
Message: "Query param 'offset' must be a valid integer",
Message: "Query param 'offset' must be a valid integer.",
Validations: []httpapi.Error{
{Field: "offset", Detail: err.Error()},
},