mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-25 03:19:55 +01:00
Fix error comparisons
This commit is contained in:
parent
7b0a8f47de
commit
db67c1277e
27 changed files with 93 additions and 73 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
_ "embed"
|
||||
"errors"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
|
|
@ -67,7 +68,7 @@ func (s *Router) getLinkStatus(w http.ResponseWriter, r *http.Request) {
|
|||
resp := map[string]interface{}{}
|
||||
u, _ := request.UserFrom(r.Context())
|
||||
key, err := s.sessionKeys.Get(r.Context(), u.ID)
|
||||
if err != nil && err != model.ErrNotFound {
|
||||
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
||||
resp["error"] = err
|
||||
resp["status"] = false
|
||||
_ = rest.RespondWithJSON(w, http.StatusInternalServerError, resp)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package listenbrainz
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/deluan/rest"
|
||||
|
|
@ -62,7 +63,7 @@ func (s *Router) getLinkStatus(w http.ResponseWriter, r *http.Request) {
|
|||
resp := map[string]interface{}{}
|
||||
u, _ := request.UserFrom(r.Context())
|
||||
key, err := s.sessionKeys.Get(r.Context(), u.ID)
|
||||
if err != nil && err != model.ErrNotFound {
|
||||
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
||||
resp["error"] = err
|
||||
resp["status"] = false
|
||||
_ = rest.RespondWithJSON(w, http.StatusInternalServerError, resp)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package spotify
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sort"
|
||||
|
|
@ -46,7 +47,7 @@ func (s *spotifyAgent) AgentName() string {
|
|||
func (s *spotifyAgent) GetImages(ctx context.Context, id, name, mbid string) ([]agents.ArtistImage, error) {
|
||||
a, err := s.searchArtist(ctx, name)
|
||||
if err != nil {
|
||||
if err == model.ErrNotFound {
|
||||
if errors.Is(err, model.ErrNotFound) {
|
||||
log.Warn(ctx, "Artist not found in Spotify", "artist", name)
|
||||
} else {
|
||||
log.Error(ctx, "Error calling Spotify", "artist", name, err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue