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

@ -46,13 +46,13 @@ func ExtractOrganizationParam(db database.Store) func(http.Handler) http.Handler
organization, err := db.GetOrganizationByID(r.Context(), orgID)
if errors.Is(err, sql.ErrNoRows) {
httpapi.Write(rw, http.StatusNotFound, httpapi.Response{
Message: fmt.Sprintf("Organization %q does not exist", orgID),
Message: fmt.Sprintf("Organization %q does not exist.", orgID),
})
return
}
if err != nil {
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{
Message: "Internal error fetching organization",
Message: "Internal error fetching organization.",
Detail: err.Error(),
})
return
@ -77,13 +77,13 @@ func ExtractOrganizationMemberParam(db database.Store) func(http.Handler) http.H
})
if errors.Is(err, sql.ErrNoRows) {
httpapi.Write(rw, http.StatusForbidden, httpapi.Response{
Message: "Not a member of the organization",
Message: "Not a member of the organization.",
})
return
}
if err != nil {
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{
Message: "Internal error fetching organization member",
Message: "Internal error fetching organization member.",
Detail: err.Error(),
})
return