From 42dbfa7a85a25fcb80f2936ac7949d50ed1bfbf8 Mon Sep 17 00:00:00 2001 From: sentriz Date: Sun, 14 Jan 2024 12:18:31 +0000 Subject: [PATCH] fix(subsonic): return error code 70 for not found errors in more places fixes #454 --- server/ctrlsubsonic/handlers_by_tags.go | 6 +++--- server/ctrlsubsonic/handlers_common.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/ctrlsubsonic/handlers_by_tags.go b/server/ctrlsubsonic/handlers_by_tags.go index bb0af774..5a2fa8f2 100644 --- a/server/ctrlsubsonic/handlers_by_tags.go +++ b/server/ctrlsubsonic/handlers_by_tags.go @@ -120,7 +120,7 @@ func (c *Controller) ServeGetAlbum(r *http.Request) *spec.Response { First(album, id.Value). Error if errors.Is(err, gorm.ErrRecordNotFound) { - return spec.NewError(10, "couldn't find an album with that id") + return spec.NewError(70, "couldn't find an album with that id") } sub := spec.NewResponse() sub.Album = spec.NewAlbumByTags(album, album.Artists) @@ -649,7 +649,7 @@ func (c *Controller) ServeGetSimilarSongs(r *http.Request) *spec.Response { First(&track). Error if errors.Is(err, gorm.ErrRecordNotFound) { - return spec.NewError(10, "couldn't find a track with that id") + return spec.NewError(70, "couldn't find a track with that id") } similarTracks, err := c.lastFMClient.TrackGetSimilarTracks(track.TagTrackArtist, track.TagTitle) @@ -715,7 +715,7 @@ func (c *Controller) ServeGetSimilarSongsTwo(r *http.Request) *spec.Response { First(&artist). Error if errors.Is(err, gorm.ErrRecordNotFound) { - return spec.NewError(0, "artist with id %q not found", id) + return spec.NewError(70, "artist with id %q not found", id) } similarArtists, err := c.lastFMClient.ArtistGetSimilar(artist.Name) diff --git a/server/ctrlsubsonic/handlers_common.go b/server/ctrlsubsonic/handlers_common.go index ac1ef70b..1ee6484a 100644 --- a/server/ctrlsubsonic/handlers_common.go +++ b/server/ctrlsubsonic/handlers_common.go @@ -278,7 +278,7 @@ func (c *Controller) ServeGetSong(r *http.Request) *spec.Response { First(&track). Error if errors.Is(err, gorm.ErrRecordNotFound) { - return spec.NewError(10, "couldn't find a track with that id") + return spec.NewError(70, "couldn't find a track with that id") } transcodeMeta := streamGetTranscodeMeta(c.dbc, user.ID, params.GetOr("c", ""))