Sfoglia il codice sorgente

clearer errors

"Not found" should only be for http path/method not found (404)
if it's about specific resources, we should be explicit for clarity
Dieter Plaetinck 10 anni fa
parent
commit
66ba19b7ba

+ 1 - 1
pkg/api/dashboard_snapshot.go

@@ -59,7 +59,7 @@ func GetDashboardSnapshot(c *middleware.Context) {
 
 	// expired snapshots should also be removed from db
 	if snapshot.Expires.Before(time.Now()) {
-		c.JsonApiErr(404, "Snapshot not found", err)
+		c.JsonApiErr(404, "Dashboard snapshot not found", err)
 		return
 	}
 

+ 1 - 0
pkg/models/dashboards.go

@@ -11,6 +11,7 @@ import (
 // Typed errors
 var (
 	ErrDashboardNotFound           = errors.New("Dashboard not found")
+	ErrDashboardSnapshotNotFound   = errors.New("Dashboard snapshot not found")
 	ErrDashboardWithSameNameExists = errors.New("A dashboard with the same name already exists")
 	ErrDashboardVersionMismatch    = errors.New("The dashboard has been changed by someone else")
 )

+ 0 - 4
pkg/models/models.go

@@ -1,7 +1,5 @@
 package models
 
-import "errors"
-
 type OAuthType int
 
 const (
@@ -9,5 +7,3 @@ const (
 	GOOGLE
 	TWITTER
 )
-
-var ErrNotFound = errors.New("Not found")

+ 1 - 1
pkg/services/sqlstore/dashboard_snapshot.go

@@ -57,7 +57,7 @@ func GetDashboardSnapshot(query *m.GetDashboardSnapshotQuery) error {
 	if err != nil {
 		return err
 	} else if has == false {
-		return m.ErrNotFound
+		return m.ErrDashboardSnapshotNotFound
 	}
 
 	query.Result = &snapshot