Skip to content

Commit 42dbfa7

Browse files
committed
fix(subsonic): return error code 70 for not found errors in more places
fixes #454
1 parent e978716 commit 42dbfa7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

server/ctrlsubsonic/handlers_by_tags.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (c *Controller) ServeGetAlbum(r *http.Request) *spec.Response {
120120
First(album, id.Value).
121121
Error
122122
if errors.Is(err, gorm.ErrRecordNotFound) {
123-
return spec.NewError(10, "couldn't find an album with that id")
123+
return spec.NewError(70, "couldn't find an album with that id")
124124
}
125125
sub := spec.NewResponse()
126126
sub.Album = spec.NewAlbumByTags(album, album.Artists)
@@ -649,7 +649,7 @@ func (c *Controller) ServeGetSimilarSongs(r *http.Request) *spec.Response {
649649
First(&track).
650650
Error
651651
if errors.Is(err, gorm.ErrRecordNotFound) {
652-
return spec.NewError(10, "couldn't find a track with that id")
652+
return spec.NewError(70, "couldn't find a track with that id")
653653
}
654654

655655
similarTracks, err := c.lastFMClient.TrackGetSimilarTracks(track.TagTrackArtist, track.TagTitle)
@@ -715,7 +715,7 @@ func (c *Controller) ServeGetSimilarSongsTwo(r *http.Request) *spec.Response {
715715
First(&artist).
716716
Error
717717
if errors.Is(err, gorm.ErrRecordNotFound) {
718-
return spec.NewError(0, "artist with id %q not found", id)
718+
return spec.NewError(70, "artist with id %q not found", id)
719719
}
720720

721721
similarArtists, err := c.lastFMClient.ArtistGetSimilar(artist.Name)

server/ctrlsubsonic/handlers_common.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ func (c *Controller) ServeGetSong(r *http.Request) *spec.Response {
278278
First(&track).
279279
Error
280280
if errors.Is(err, gorm.ErrRecordNotFound) {
281-
return spec.NewError(10, "couldn't find a track with that id")
281+
return spec.NewError(70, "couldn't find a track with that id")
282282
}
283283

284284
transcodeMeta := streamGetTranscodeMeta(c.dbc, user.ID, params.GetOr("c", ""))

0 commit comments

Comments
 (0)