Chore: Differentiate the ErrOrgNotFound error messages (#64131)
* Better org not found error messages
This commit is contained in:
@@ -70,14 +70,14 @@ func (hs *HTTPServer) AdminCreateUser(c *contextmodel.ReqContext) response.Respo
|
||||
usr, err := hs.userService.Create(c.Req.Context(), &cmd)
|
||||
if err != nil {
|
||||
if errors.Is(err, org.ErrOrgNotFound) {
|
||||
return response.Error(400, err.Error(), nil)
|
||||
return response.Error(http.StatusBadRequest, err.Error(), nil)
|
||||
}
|
||||
|
||||
if errors.Is(err, user.ErrUserAlreadyExists) {
|
||||
return response.Error(412, fmt.Sprintf("User with email '%s' or username '%s' already exists", form.Email, form.Login), err)
|
||||
return response.Error(http.StatusPreconditionFailed, fmt.Sprintf("User with email '%s' or username '%s' already exists", form.Email, form.Login), err)
|
||||
}
|
||||
|
||||
return response.Error(500, "failed to create user", err)
|
||||
return response.Error(http.StatusInternalServerError, "failed to create user", err)
|
||||
}
|
||||
|
||||
metrics.MApiAdminUserCreate.Inc()
|
||||
|
||||
Reference in New Issue
Block a user