user-mgmt: clear err messages + page rendering
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ef6ef17715
commit
1f11b71341
@ -431,25 +431,7 @@ func ViewUser(client *ent.Client) echo.HandlerFunc {
|
||||
if errors.Is(err, moduser.ErrUserNotFound) { //nolint:gocritic
|
||||
c.Logger().Errorf("user not found by ID: '%s'", uid.ID)
|
||||
|
||||
return renderErrorPage(
|
||||
c,
|
||||
http.StatusNotFound,
|
||||
http.StatusText(http.StatusNotFound)+" no such user",
|
||||
err.Error(),
|
||||
)
|
||||
} else if errors.Is(err, moduser.ErrFailedToQueryUser) {
|
||||
c.Logger().Errorf("failed to query user by ID: '%s'", uid.ID)
|
||||
|
||||
return renderErrorPage(
|
||||
c,
|
||||
http.StatusInternalServerError,
|
||||
http.StatusText(http.StatusInternalServerError),
|
||||
err.Error(),
|
||||
)
|
||||
} else if errors.Is(err, moduser.ErrBadUUID) {
|
||||
c.Logger().Errorf("invalid UUID '%s': %q", uid.ID, err)
|
||||
|
||||
data["flash"] = fmt.Sprintf("%s: %q", err.Error(), uid.ID)
|
||||
data["flash"] = fmt.Sprintf("No user found with the UUID: %q", uid.ID)
|
||||
p.Data = data
|
||||
|
||||
return c.Render(
|
||||
@ -457,6 +439,28 @@ func ViewUser(client *ent.Client) echo.HandlerFunc {
|
||||
"manage/user-details.tmpl",
|
||||
p,
|
||||
)
|
||||
} else if errors.Is(err, moduser.ErrFailedToQueryUser) {
|
||||
c.Logger().Errorf("failed to query user by ID: '%s'", uid.ID)
|
||||
|
||||
data["flash"] = fmt.Sprintf("failed to query user by UUID %q", uid.ID)
|
||||
p.Data = data
|
||||
|
||||
return c.Render(
|
||||
http.StatusInternalServerError,
|
||||
"manage/user-details.tmpl",
|
||||
p,
|
||||
)
|
||||
} else if errors.Is(err, moduser.ErrBadUUID) {
|
||||
c.Logger().Errorf("Invalid UUID '%s': %q", uid.ID, err)
|
||||
|
||||
data["flash"] = fmt.Sprintf("invalid UUID %q", uid.ID)
|
||||
p.Data = data
|
||||
|
||||
return c.Render(
|
||||
http.StatusBadRequest,
|
||||
"manage/user-details.tmpl",
|
||||
p,
|
||||
)
|
||||
}
|
||||
|
||||
c.Logger().Errorf("UUID-related issue for UUID '%s': %q", uid.ID, err)
|
||||
|
Loading…
Reference in New Issue
Block a user