Removing engine.ErrDataNotFound in favor of domain.ErrNotFound

This commit is contained in:
Deluan
2016-03-23 18:15:14 -04:00
parent c50b0bdc48
commit 1ed8c60130
10 changed files with 15 additions and 19 deletions
+2 -2
View File
@@ -2,11 +2,11 @@ package api
import ( import (
"fmt" "fmt"
"time" "time"
"github.com/astaxie/beego" "github.com/astaxie/beego"
"github.com/deluan/gosonic/api/responses" "github.com/deluan/gosonic/api/responses"
"github.com/deluan/gosonic/domain"
"github.com/deluan/gosonic/engine" "github.com/deluan/gosonic/engine"
"github.com/deluan/gosonic/utils" "github.com/deluan/gosonic/utils"
) )
@@ -69,7 +69,7 @@ func (c *BrowsingController) GetDirectory() {
dir, err := c.browser.Directory(id) dir, err := c.browser.Directory(id)
switch { switch {
case err == engine.ErrDataNotFound: case err == domain.ErrNotFound:
beego.Error("Requested Id", id, "not found:", err) beego.Error("Requested Id", id, "not found:", err)
c.SendError(responses.ErrorDataNotFound, "Directory not found") c.SendError(responses.ErrorDataNotFound, "Directory not found")
case err != nil: case err != nil:
+4 -3
View File
@@ -6,6 +6,7 @@ import (
"github.com/astaxie/beego" "github.com/astaxie/beego"
"github.com/deluan/gosonic/api/responses" "github.com/deluan/gosonic/api/responses"
"github.com/deluan/gosonic/domain"
"github.com/deluan/gosonic/engine" "github.com/deluan/gosonic/engine"
"github.com/deluan/gosonic/utils" "github.com/deluan/gosonic/utils"
) )
@@ -26,9 +27,9 @@ func (c *MediaAnnotationController) Star() {
beego.Debug("Starring ids:", ids) beego.Debug("Starring ids:", ids)
err := c.ratings.SetStar(true, ids...) err := c.ratings.SetStar(true, ids...)
switch { switch {
case err == engine.ErrDataNotFound: case err == domain.ErrNotFound:
beego.Error(err) beego.Error(err)
c.SendError(responses.ErrorDataNotFound, "Directory not found") c.SendError(responses.ErrorDataNotFound, "Id not found")
case err != nil: case err != nil:
beego.Error(err) beego.Error(err)
c.SendError(responses.ErrorGeneric, "Internal Error") c.SendError(responses.ErrorGeneric, "Internal Error")
@@ -43,7 +44,7 @@ func (c *MediaAnnotationController) Unstar() {
beego.Debug("Unstarring ids:", ids) beego.Debug("Unstarring ids:", ids)
err := c.ratings.SetStar(false, ids...) err := c.ratings.SetStar(false, ids...)
switch { switch {
case err == engine.ErrDataNotFound: case err == domain.ErrNotFound:
beego.Error(err) beego.Error(err)
c.SendError(responses.ErrorDataNotFound, "Directory not found") c.SendError(responses.ErrorDataNotFound, "Directory not found")
case err != nil: case err != nil:
+2 -1
View File
@@ -6,6 +6,7 @@ import (
"github.com/astaxie/beego" "github.com/astaxie/beego"
"github.com/deluan/gosonic/api/responses" "github.com/deluan/gosonic/api/responses"
"github.com/deluan/gosonic/domain"
"github.com/deluan/gosonic/engine" "github.com/deluan/gosonic/engine"
"github.com/deluan/gosonic/utils" "github.com/deluan/gosonic/utils"
) )
@@ -37,7 +38,7 @@ func (c *MediaRetrievalController) GetCover() {
err := c.cover.Get(id, size, c.Ctx.ResponseWriter) err := c.cover.Get(id, size, c.Ctx.ResponseWriter)
switch { switch {
case err == engine.ErrDataNotFound: case err == domain.ErrNotFound:
beego.Error(err, "Id:", id) beego.Error(err, "Id:", id)
c.SendError(responses.ErrorDataNotFound, "Directory not found") c.SendError(responses.ErrorDataNotFound, "Directory not found")
case err != nil: case err != nil:
+2 -1
View File
@@ -3,6 +3,7 @@ package api
import ( import (
"github.com/astaxie/beego" "github.com/astaxie/beego"
"github.com/deluan/gosonic/api/responses" "github.com/deluan/gosonic/api/responses"
"github.com/deluan/gosonic/domain"
"github.com/deluan/gosonic/engine" "github.com/deluan/gosonic/engine"
"github.com/deluan/gosonic/utils" "github.com/deluan/gosonic/utils"
) )
@@ -42,7 +43,7 @@ func (c *PlaylistsController) Get() {
pinfo, err := c.pls.Get(id) pinfo, err := c.pls.Get(id)
switch { switch {
case err == engine.ErrDataNotFound: case err == domain.ErrNotFound:
beego.Error(err, "Id:", id) beego.Error(err, "Id:", id)
c.SendError(responses.ErrorDataNotFound, "Directory not found") c.SendError(responses.ErrorDataNotFound, "Directory not found")
case err != nil: case err != nil:
+1 -1
View File
@@ -82,7 +82,7 @@ func (b *browser) Directory(id string) (*DirectoryInfo, error) {
dir = b.buildAlbumDir(al, tracks) dir = b.buildAlbumDir(al, tracks)
default: default:
beego.Debug("Id", id, "not found") beego.Debug("Id", id, "not found")
return nil, ErrDataNotFound return nil, domain.ErrNotFound
} }
return dir, nil return dir, nil
-5
View File
@@ -1,7 +1,6 @@
package engine package engine
import ( import (
"errors"
"time" "time"
"github.com/deluan/gosonic/domain" "github.com/deluan/gosonic/domain"
@@ -41,10 +40,6 @@ type Entry struct {
type Entries []Entry type Entries []Entry
var (
ErrDataNotFound = errors.New("data not found")
)
func FromAlbum(al *domain.Album) Entry { func FromAlbum(al *domain.Album) Entry {
e := Entry{} e := Entry{}
e.Id = al.Id e.Id = al.Id
+1 -1
View File
@@ -46,7 +46,7 @@ func (c *cover) Get(id string, size int, out io.Writer) error {
} }
if err != nil { if err != nil {
return ErrDataNotFound return domain.ErrNotFound
} }
if size > 0 { if size > 0 {
+2 -1
View File
@@ -6,6 +6,7 @@ import (
"bytes" "bytes"
"image" "image"
"github.com/deluan/gosonic/domain"
"github.com/deluan/gosonic/engine" "github.com/deluan/gosonic/engine"
"github.com/deluan/gosonic/persistence" "github.com/deluan/gosonic/persistence"
. "github.com/deluan/gosonic/tests" . "github.com/deluan/gosonic/tests"
@@ -53,7 +54,7 @@ func TestCover(t *testing.T) {
err := cover.Get("2", 0, out) err := cover.Get("2", 0, out)
Convey("Then it should return DatNotFound error", func() { Convey("Then it should return DatNotFound error", func() {
So(err, ShouldEqual, engine.ErrDataNotFound) So(err, ShouldEqual, domain.ErrNotFound)
}) })
}) })
Convey("When specifying a size", func() { Convey("When specifying a size", func() {
-3
View File
@@ -34,9 +34,6 @@ type PlaylistInfo struct {
func (p *playlists) Get(id string) (*PlaylistInfo, error) { func (p *playlists) Get(id string) (*PlaylistInfo, error) {
pl, err := p.plsRepo.Get(id) pl, err := p.plsRepo.Get(id)
if err == domain.ErrNotFound {
return nil, ErrDataNotFound
}
if err != nil { if err != nil {
return nil, err return nil, err
} }
+1 -1
View File
@@ -46,7 +46,7 @@ func (r ratings) SetStar(star bool, ids ...string) error {
} }
continue continue
} }
return ErrDataNotFound return domain.ErrNotFound
} }
return nil return nil