mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
@@ -17,7 +17,7 @@ const (
|
||||
// userErrorMessage is a constant so that no information about the state
|
||||
// of the queried user can be gained. We return the same error if the user
|
||||
// does not exist, or if the input is just garbage.
|
||||
userErrorMessage = "\"user\" must be an existing uuid or username"
|
||||
userErrorMessage = "\"user\" must be an existing uuid or username."
|
||||
)
|
||||
|
||||
// UserParam returns the user from the ExtractUserParam handler.
|
||||
@@ -40,7 +40,7 @@ func ExtractUserParam(db database.Store) func(http.Handler) http.Handler {
|
||||
userQuery := chi.URLParam(r, "user")
|
||||
if userQuery == "" {
|
||||
httpapi.Write(rw, http.StatusBadRequest, httpapi.Response{
|
||||
Message: "\"user\" must be provided",
|
||||
Message: "\"user\" must be provided.",
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -49,7 +49,7 @@ func ExtractUserParam(db database.Store) func(http.Handler) http.Handler {
|
||||
user, err = db.GetUserByID(r.Context(), APIKey(r).UserID)
|
||||
if err != nil {
|
||||
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{
|
||||
Message: "Internal error fetching user",
|
||||
Message: "Internal error fetching user.",
|
||||
Detail: err.Error(),
|
||||
})
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user