fix: surface segment save errors in editor

This commit is contained in:
2026-05-22 16:41:33 +02:00
parent 51355a4dbc
commit 23246e2326
2 changed files with 9 additions and 4 deletions

View File

@@ -205,7 +205,7 @@ func (h *PlaybackHandler) HandleUpsertSkipSegment(c *gin.Context) {
userID = u.ID
}
if userID == "" {
c.Status(http.StatusUnauthorized)
c.JSON(http.StatusUnauthorized, gin.H{"error": "login required"})
return
}
@@ -217,12 +217,12 @@ func (h *PlaybackHandler) HandleUpsertSkipSegment(c *gin.Context) {
EndTime float64 `json:"end_time"`
}
if err := c.ShouldBindJSON(&req); err != nil {
c.Status(http.StatusBadRequest)
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid request body"})
return
}
if err := h.svc.UpsertSkipSegmentOverride(c.Request.Context(), userID, req.MalID, req.Episode, req.SkipType, req.StartTime, req.EndTime); err != nil {
c.Status(http.StatusBadRequest)
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}

View File

@@ -140,7 +140,12 @@ export const setupSegmentEditor = (): void => {
}),
});
if (!res.ok) {
setError(res.status === 401 ? 'Login required.' : 'Failed to save segment.');
let message = res.status === 401 ? 'Login required.' : 'Failed to save segment.';
try {
const payload = (await res.json()) as { error?: string };
if (payload?.error) message = payload.error;
} catch {}
setError(message);
return;
}