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:
@@ -35,19 +35,20 @@ func ExtractTemplateParam(db database.Store) func(http.Handler) http.Handler {
|
||||
template, err := db.GetTemplateByID(r.Context(), templateID)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
httpapi.Write(rw, http.StatusNotFound, httpapi.Response{
|
||||
Message: fmt.Sprintf("template %q does not exist", templateID),
|
||||
Message: fmt.Sprintf("Template %q does not exist", templateID),
|
||||
})
|
||||
}
|
||||
if err != nil {
|
||||
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{
|
||||
Message: fmt.Sprintf("get template: %s", err),
|
||||
Message: "Internal error fetching template",
|
||||
Detail: err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if template.Deleted {
|
||||
httpapi.Write(rw, http.StatusNotFound, httpapi.Response{
|
||||
Message: fmt.Sprintf("template %q does not exist", templateID),
|
||||
Message: fmt.Sprintf("Template %q does not exist", templateID),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user