Skip to content

Commit

Permalink
clearer errors
Browse files Browse the repository at this point in the history
"Not found" should only be for http path/method not found (404)
if it's about specific resources, we should be explicit for clarity
  • Loading branch information
Dieterbe authored and torkelo committed Jul 8, 2015
1 parent f6ad386 commit 66ba19b
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/api/dashboard_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions pkg/models/dashboards.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
Expand Down
4 changes: 0 additions & 4 deletions pkg/models/models.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package models

import "errors"

type OAuthType int

const (
GITHUB OAuthType = iota + 1
GOOGLE
TWITTER
)

var ErrNotFound = errors.New("Not found")
2 changes: 1 addition & 1 deletion pkg/services/sqlstore/dashboard_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 66ba19b

Please sign in to comment.