mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: Update BE http errors to be ui friendly (#1994)
* chore: More UI friendly errors Mainly capitlization + messages prefix error
This commit is contained in:
+12
-4
@@ -1,7 +1,6 @@
|
||||
package coderd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -25,7 +24,10 @@ 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: fmt.Sprintf("after_id must be a valid uuid: %s", err.Error()),
|
||||
Message: "Query param 'after_id' must be a valid UUID",
|
||||
Validations: []httpapi.Error{
|
||||
{Field: "after_id", Detail: err.Error()},
|
||||
},
|
||||
})
|
||||
return p, false
|
||||
}
|
||||
@@ -34,7 +36,10 @@ 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: fmt.Sprintf("limit must be an integer: %s", err.Error()),
|
||||
Message: "Query param 'limit' must be a valid integer",
|
||||
Validations: []httpapi.Error{
|
||||
{Field: "limit", Detail: err.Error()},
|
||||
},
|
||||
})
|
||||
return p, false
|
||||
}
|
||||
@@ -43,7 +48,10 @@ 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: fmt.Sprintf("offset must be an integer: %s", err.Error()),
|
||||
Message: "Query param 'offset' must be a valid integer",
|
||||
Validations: []httpapi.Error{
|
||||
{Field: "offset", Detail: err.Error()},
|
||||
},
|
||||
})
|
||||
return p, false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user