refactor(server/api): migrate auth/me handlers to writeErr(err) (T3a)

This commit is contained in:
2026-05-07 20:25:26 -04:00
parent 58766dbebe
commit e382b0d718
9 changed files with 66 additions and 56 deletions
+3 -2
View File
@@ -6,6 +6,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"
)
@@ -25,7 +26,7 @@ type systemPlaylistsStatusResp struct {
func (h *handlers) handleGetSystemPlaylistsStatus(w http.ResponseWriter, r *http.Request) {
caller, ok := auth.UserFromContext(r.Context())
if !ok {
writeErr(w, http.StatusUnauthorized, "unauthenticated", "no session")
writeErr(w, apierror.Unauthorized("unauthenticated", "no session"))
return
}
@@ -36,7 +37,7 @@ func (h *handlers) handleGetSystemPlaylistsStatus(w http.ResponseWriter, r *http
return
}
h.logger.Error("api: get system playlists status", "err", err)
writeErr(w, http.StatusInternalServerError, "server_error", "lookup failed")
writeErr(w, apierror.InternalMsg("lookup failed", err))
return
}