aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2023-05-09 10:00:07 +0200
committerTaras Madan <tarasmadan@google.com>2023-05-09 11:48:04 +0200
commit8d2f31fec94a28399e75d783d1d6231711da649f (patch)
tree5ecb877601b35f0948d69e612fcb7eb091e82d8c
parentf41681037faf693b3f0c5ab1023d90ad97b572c2 (diff)
dashboard/app: change client errors format
-rw-r--r--dashboard/app/access.go4
-rw-r--r--dashboard/app/main.go10
2 files changed, 7 insertions, 7 deletions
diff --git a/dashboard/app/access.go b/dashboard/app/access.go
index 1336e7a3a..7ad85da09 100644
--- a/dashboard/app/access.go
+++ b/dashboard/app/access.go
@@ -118,7 +118,7 @@ func checkCrashTextAccess(c context.Context, r *http.Request, field string, id i
if len(crashes) != 1 {
err := fmt.Errorf("checkCrashTextAccess: found %v crashes for %v=%v", len(crashes), field, id)
if len(crashes) == 0 {
- err = fmt.Errorf("%v: %w", err, ErrClientNotFound)
+ err = fmt.Errorf("%w: %v", ErrClientNotFound, err)
}
return nil, nil, err
}
@@ -143,7 +143,7 @@ func checkJobTextAccess(c context.Context, r *http.Request, field string, id int
err := fmt.Errorf("checkJobTextAccess: found %v jobs for %v=%v", len(keys), field, id)
if len(keys) == 0 {
// This can be triggered by bad user requests, so don't log the error.
- err = fmt.Errorf("%v: %w", err, ErrClientNotFound)
+ err = fmt.Errorf("%w: %v", ErrClientNotFound, err)
}
return err
}
diff --git a/dashboard/app/main.go b/dashboard/app/main.go
index ff82e015a..b8b3f1e38 100644
--- a/dashboard/app/main.go
+++ b/dashboard/app/main.go
@@ -501,7 +501,7 @@ func handleSubsystemPage(c context.Context, w http.ResponseWriter, r *http.Reque
subsystem = service.ByName(r.URL.Path[pos+3:])
}
if subsystem == nil {
- return fmt.Errorf("the subsystem is not found in the path %v: %w", r.URL.Path, ErrClientBadRequest)
+ return fmt.Errorf("%w: the subsystem is not found in the path %v", ErrClientBadRequest, r.URL.Path)
}
groups, err := fetchNamespaceBugs(c, accessLevel(c, r),
hdr.Namespace, &userBugFilter{
@@ -677,7 +677,7 @@ func handleAdmin(c context.Context, w http.ResponseWriter, r *http.Request) erro
func handleBug(c context.Context, w http.ResponseWriter, r *http.Request) error {
bug, err := findBugByID(c, r)
if err != nil {
- return fmt.Errorf("%v, %w", err, ErrClientNotFound)
+ return fmt.Errorf("%w: %v", ErrClientNotFound, err)
}
accessLevel := accessLevel(c, r)
if err := checkAccessLevel(c, r, bug.sanitizeAccess(accessLevel)); err != nil {
@@ -1092,14 +1092,14 @@ func handleTextImpl(c context.Context, w http.ResponseWriter, r *http.Request, t
if x := r.FormValue("x"); x != "" {
xid, err := strconv.ParseUint(x, 16, 64)
if err != nil || xid == 0 {
- return fmt.Errorf("failed to parse text id: %v: %w", err, ErrClientBadRequest)
+ return fmt.Errorf("%w: failed to parse text id: %v", ErrClientBadRequest, err)
}
id = int64(xid)
} else {
// Old link support, don't remove.
xid, err := strconv.ParseInt(r.FormValue("id"), 10, 64)
if err != nil || xid == 0 {
- return fmt.Errorf("failed to parse text id: %v: %w", err, ErrClientBadRequest)
+ return fmt.Errorf("%w: failed to parse text id: %v", ErrClientBadRequest, err)
}
id = xid
}
@@ -1110,7 +1110,7 @@ func handleTextImpl(c context.Context, w http.ResponseWriter, r *http.Request, t
data, ns, err := getText(c, tag, id)
if err != nil {
if strings.Contains(err.Error(), "datastore: no such entity") {
- err = fmt.Errorf("%v: %w", err, ErrClientBadRequest)
+ err = fmt.Errorf("%w: %v", ErrClientBadRequest, err)
}
return err
}