🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Removing engine.ErrDataNotFound in favor of domain.ErrNotFound
Deluan1ed8c601303c
diff --git a/api/browsing.go b/api/browsing.goindex 85e156bd7..a82e198f2 100644--- a/api/browsing.go+++ b/api/browsing.go@@ -2,11 +2,11 @@ package apiimport ("fmt"-"time""github.com/astaxie/beego""github.com/deluan/gosonic/api/responses"+ "github.com/deluan/gosonic/domain""github.com/deluan/gosonic/engine""github.com/deluan/gosonic/utils")@@ -69,7 +69,7 @@ func (c *BrowsingController) GetDirectory() {dir, err := c.browser.Directory(id)switch {- case err == engine.ErrDataNotFound:+ case err == domain.ErrNotFound:beego.Error("Requested Id", id, "not found:", err)c.SendError(responses.ErrorDataNotFound, "Directory not found")case err != nil:diff --git a/api/media_annotation.go b/api/media_annotation.goindex 7209b98d8..5ad791e5c 100644--- a/api/media_annotation.go+++ b/api/media_annotation.go@@ -6,6 +6,7 @@ import ("github.com/astaxie/beego""github.com/deluan/gosonic/api/responses"+ "github.com/deluan/gosonic/domain""github.com/deluan/gosonic/engine""github.com/deluan/gosonic/utils")@@ -26,9 +27,9 @@ func (c *MediaAnnotationController) Star() {beego.Debug("Starring ids:", ids)err := c.ratings.SetStar(true, ids...)switch {- case err == engine.ErrDataNotFound:+ case err == domain.ErrNotFound:beego.Error(err)- c.SendError(responses.ErrorDataNotFound, "Directory not found")+ c.SendError(responses.ErrorDataNotFound, "Id not found")case err != nil:beego.Error(err)c.SendError(responses.ErrorGeneric, "Internal Error")@@ -43,7 +44,7 @@ func (c *MediaAnnotationController) Unstar() {beego.Debug("Unstarring ids:", ids)err := c.ratings.SetStar(false, ids...)switch {- case err == engine.ErrDataNotFound:+ case err == domain.ErrNotFound:beego.Error(err)c.SendError(responses.ErrorDataNotFound, "Directory not found")case err != nil:diff --git a/api/media_retrieval.go b/api/media_retrieval.goindex efcfe6ac5..ed8723834 100644--- a/api/media_retrieval.go+++ b/api/media_retrieval.go@@ -6,6 +6,7 @@ import ("github.com/astaxie/beego""github.com/deluan/gosonic/api/responses"+ "github.com/deluan/gosonic/domain""github.com/deluan/gosonic/engine""github.com/deluan/gosonic/utils")@@ -37,7 +38,7 @@ func (c *MediaRetrievalController) GetCover() {err := c.cover.Get(id, size, c.Ctx.ResponseWriter)switch {- case err == engine.ErrDataNotFound:+ case err == domain.ErrNotFound:beego.Error(err, "Id:", id)c.SendError(responses.ErrorDataNotFound, "Directory not found")case err != nil:diff --git a/api/playlists.go b/api/playlists.goindex d05e997f4..c82bbaadc 100644--- a/api/playlists.go+++ b/api/playlists.go@@ -3,6 +3,7 @@ package apiimport ("github.com/astaxie/beego""github.com/deluan/gosonic/api/responses"+ "github.com/deluan/gosonic/domain""github.com/deluan/gosonic/engine""github.com/deluan/gosonic/utils")@@ -42,7 +43,7 @@ func (c *PlaylistsController) Get() {pinfo, err := c.pls.Get(id)switch {- case err == engine.ErrDataNotFound:+ case err == domain.ErrNotFound:beego.Error(err, "Id:", id)c.SendError(responses.ErrorDataNotFound, "Directory not found")case err != nil:diff --git a/engine/browser.go b/engine/browser.goindex fb22faa85..e2dd5e989 100644--- a/engine/browser.go+++ b/engine/browser.go@@ -82,7 +82,7 @@ func (b *browser) Directory(id string) (*DirectoryInfo, error) {dir = b.buildAlbumDir(al, tracks)default:beego.Debug("Id", id, "not found")- return nil, ErrDataNotFound+ return nil, domain.ErrNotFound}return dir, nildiff --git a/engine/common.go b/engine/common.goindex 36773605b..01506d94c 100644--- a/engine/common.go+++ b/engine/common.go@@ -1,7 +1,6 @@package engineimport (- "errors""time""github.com/deluan/gosonic/domain"@@ -41,10 +40,6 @@ type Entry struct {type Entries []Entry-var (- ErrDataNotFound = errors.New("data not found")-)-func FromAlbum(al *domain.Album) Entry {e := Entry{}e.Id = al.Iddiff --git a/engine/cover.go b/engine/cover.goindex 8a18affbd..cdb40ee41 100644--- a/engine/cover.go+++ b/engine/cover.go@@ -46,7 +46,7 @@ func (c *cover) Get(id string, size int, out io.Writer) error {}if err != nil {- return ErrDataNotFound+ return domain.ErrNotFound}if size > 0 {diff --git a/engine/cover_test.go b/engine/cover_test.goindex 073be3f02..aeab41445 100644--- a/engine/cover_test.go+++ b/engine/cover_test.go@@ -6,6 +6,7 @@ import ("bytes""image"+ "github.com/deluan/gosonic/domain""github.com/deluan/gosonic/engine""github.com/deluan/gosonic/persistence". "github.com/deluan/gosonic/tests"@@ -53,7 +54,7 @@ func TestCover(t *testing.T) {err := cover.Get("2", 0, out)Convey("Then it should return DatNotFound error", func() {- So(err, ShouldEqual, engine.ErrDataNotFound)+ So(err, ShouldEqual, domain.ErrNotFound)})})Convey("When specifying a size", func() {diff --git a/engine/playlists.go b/engine/playlists.goindex 43a5bc548..2a6af7223 100644--- a/engine/playlists.go+++ b/engine/playlists.go@@ -34,9 +34,6 @@ type PlaylistInfo struct {func (p *playlists) Get(id string) (*PlaylistInfo, error) {pl, err := p.plsRepo.Get(id)- if err == domain.ErrNotFound {- return nil, ErrDataNotFound- }if err != nil {return nil, err}diff --git a/engine/ratings.go b/engine/ratings.goindex 651eeb080..f14be9fde 100644--- a/engine/ratings.go+++ b/engine/ratings.go@@ -46,7 +46,7 @@ func (r ratings) SetStar(star bool, ids ...string) error {}continue}- return ErrDataNotFound+ return domain.ErrNotFound}return nil