fix(manage): HandleReorder gibt 400 bei Mismatch zurück, slog für 500-Fehler
This commit is contained in:
parent
4fab5fe28a
commit
052cf199ae
2 changed files with 9 additions and 1 deletions
|
|
@ -2,7 +2,9 @@ package manage
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log/slog"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -242,7 +244,12 @@ func HandleReorder(playlists *store.PlaylistStore, notifier *mqttnotifier.Notifi
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := playlists.Reorder(r.Context(), playlistID, ids); err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -745,6 +745,7 @@ func HandleReorderUI(playlists *store.PlaylistStore, screens *store.ScreenStore,
|
||||||
if errors.Is(err, store.ErrReorderMismatch) {
|
if errors.Is(err, store.ErrReorderMismatch) {
|
||||||
http.Error(w, "item list mismatch", http.StatusBadRequest)
|
http.Error(w, "item list mismatch", http.StatusBadRequest)
|
||||||
} else {
|
} else {
|
||||||
|
slog.Error("reorder failed", "err", err)
|
||||||
http.Error(w, "db error", http.StatusInternalServerError)
|
http.Error(w, "db error", http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue