refactor(server): final writeErr migration + ErrNotFound aliases (T3c)
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/apierror"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/auth"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/db/dbq"
|
||||
"git.fabledsword.com/bvandeusen/minstrel/internal/playlists"
|
||||
@@ -37,13 +38,13 @@ type foryouRefreshResp struct {
|
||||
func (h *handlers) handleForYouRefresh(w http.ResponseWriter, r *http.Request) {
|
||||
user, ok := auth.UserFromContext(r.Context())
|
||||
if !ok {
|
||||
writeErr(w, http.StatusUnauthorized, "auth_required", "")
|
||||
writeErr(w, apierror.Unauthorized("auth_required", ""))
|
||||
return
|
||||
}
|
||||
if err := playlists.BuildSystemPlaylists(r.Context(), h.pool, h.logger, user.ID, time.Now(), h.dataDir); err != nil {
|
||||
h.logger.Error("for-you refresh: build failed",
|
||||
"user_id", uuidToString(user.ID), "err", err)
|
||||
writeErr(w, http.StatusInternalServerError, "server_error", "build failed")
|
||||
writeErr(w, apierror.InternalMsg("build failed", err))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -66,7 +67,7 @@ func (h *handlers) handleForYouRefresh(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
h.logger.Error("for-you refresh: lookup failed",
|
||||
"user_id", uuidToString(user.ID), "err", err)
|
||||
writeErr(w, http.StatusInternalServerError, "server_error", "lookup failed")
|
||||
writeErr(w, apierror.InternalMsg("lookup failed", err))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -76,7 +77,7 @@ func (h *handlers) handleForYouRefresh(w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
h.logger.Error("for-you refresh: list tracks failed",
|
||||
"playlist_id", uuidToString(pl.ID), "err", err)
|
||||
writeErr(w, http.StatusInternalServerError, "server_error", "list tracks failed")
|
||||
writeErr(w, apierror.InternalMsg("list tracks failed", err))
|
||||
return
|
||||
}
|
||||
trackIDs := make([]string, 0, len(rows))
|
||||
|
||||
Reference in New Issue
Block a user