Chore: Handle wrapped errors (#29223)
* Chore: Handle wrapped errors Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
This commit is contained in:
co-authored by
Emil Tullstedt
parent
0cb29d337a
commit
294770f411
+4
-2
@@ -1,6 +1,8 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/dtos"
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
@@ -22,7 +24,7 @@ func getUserUserProfile(userID int64) Response {
|
||||
query := models.GetUserProfileQuery{UserId: userID}
|
||||
|
||||
if err := bus.Dispatch(&query); err != nil {
|
||||
if err == models.ErrUserNotFound {
|
||||
if errors.Is(err, models.ErrUserNotFound) {
|
||||
return Error(404, models.ErrUserNotFound.Error(), nil)
|
||||
}
|
||||
return Error(500, "Failed to get user", err)
|
||||
@@ -45,7 +47,7 @@ func getUserUserProfile(userID int64) Response {
|
||||
func GetUserByLoginOrEmail(c *models.ReqContext) Response {
|
||||
query := models.GetUserByLoginQuery{LoginOrEmail: c.Query("loginOrEmail")}
|
||||
if err := bus.Dispatch(&query); err != nil {
|
||||
if err == models.ErrUserNotFound {
|
||||
if errors.Is(err, models.ErrUserNotFound) {
|
||||
return Error(404, models.ErrUserNotFound.Error(), nil)
|
||||
}
|
||||
return Error(500, "Failed to get user", err)
|
||||
|
||||
Reference in New Issue
Block a user