mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-10 03:17:27 +02:00
Fix error comparisons
This commit is contained in:
parent
7b0a8f47de
commit
db67c1277e
27 changed files with 93 additions and 73 deletions
|
|
@ -3,6 +3,7 @@ package nativeapi
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
|
@ -47,7 +48,7 @@ func handleExportPlaylist(ds model.DataStore) http.HandlerFunc {
|
|||
plsRepo := ds.Playlist(ctx)
|
||||
plsId := chi.URLParam(r, "playlistId")
|
||||
pls, err := plsRepo.GetWithTracks(plsId)
|
||||
if err == model.ErrNotFound {
|
||||
if errors.Is(err, model.ErrNotFound) {
|
||||
log.Warn("Playlist not found", "playlistId", plsId)
|
||||
http.Error(w, "not found", http.StatusNotFound)
|
||||
return
|
||||
|
|
@ -89,7 +90,7 @@ func deleteFromPlaylist(ds model.DataStore) http.HandlerFunc {
|
|||
tracksRepo := tx.Playlist(r.Context()).Tracks(playlistId)
|
||||
return tracksRepo.Delete(ids...)
|
||||
})
|
||||
if len(ids) == 1 && err == model.ErrNotFound {
|
||||
if len(ids) == 1 && errors.Is(err, model.ErrNotFound) {
|
||||
log.Warn(r.Context(), "Track not found in playlist", "playlistId", playlistId, "id", ids[0])
|
||||
http.Error(w, "not found", http.StatusNotFound)
|
||||
return
|
||||
|
|
@ -190,7 +191,7 @@ func reorderItem(ds model.DataStore) http.HandlerFunc {
|
|||
}
|
||||
tracksRepo := ds.Playlist(r.Context()).Tracks(playlistId)
|
||||
err = tracksRepo.Reorder(id, newPos)
|
||||
if err == rest.ErrPermissionDenied {
|
||||
if errors.Is(err, rest.ErrPermissionDenied) {
|
||||
http.Error(w, err.Error(), http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue