fix(manage): HandleReorder gibt 400 bei Mismatch zurück, slog für 500-Fehler

This commit is contained in:
Jesko Anschütz 2026-03-26 22:29:48 +01:00
parent 4fab5fe28a
commit 052cf199ae
2 changed files with 9 additions and 1 deletions

View file

@ -2,7 +2,9 @@ package manage
import (
"encoding/json"
"errors"
"fmt"
"log/slog"
"net/http"
"strconv"
"strings"
@ -242,7 +244,12 @@ func HandleReorder(playlists *store.PlaylistStore, notifier *mqttnotifier.Notifi
}
if err := playlists.Reorder(r.Context(), playlistID, ids); err != nil {
http.Error(w, "db error", http.StatusInternalServerError)
if errors.Is(err, store.ErrReorderMismatch) {
http.Error(w, "item list mismatch", http.StatusBadRequest)
} else {
slog.Error("reorder failed", "err", err)
http.Error(w, "db error", http.StatusInternalServerError)
}
return
}

View file

@ -745,6 +745,7 @@ func HandleReorderUI(playlists *store.PlaylistStore, screens *store.ScreenStore,
if errors.Is(err, store.ErrReorderMismatch) {
http.Error(w, "item list mismatch", http.StatusBadRequest)
} else {
slog.Error("reorder failed", "err", err)
http.Error(w, "db error", http.StatusInternalServerError)
}
return