mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-06 05:16:38 +08:00
fix: correct HTTP status codes and error handling in remaining handlers
- createPlaylistHandler: 200 → 201 Created, service errors → 500 - createSiteHandler: service/DB errors → 500 (was 400) - saveStorageConfigHandler: service errors → 500 (was 400) - SchedulerHandler.RunTask: task errors → 500 (was 400 with ErrInternal) - aria2StatsHandler: service errors → 500 (was 400) - organizeMediaHandler: service errors → 500 (was 400) - testDownloadClientHandler: test failure → 200 with ok:false (was 400) - testStorageConfigHandler: test failure → 200 with ok:false (was 400) Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
@@ -75,7 +75,7 @@ func deleteDownloadClientHandler(svc *service.Container) gin.HandlerFunc {
|
||||
func testDownloadClientHandler(svc *service.Container) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
if err := svc.DownloadClients.Test(c.Request.Context(), c.Param("id")); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"ok": false, "error": err.Error()})
|
||||
c.JSON(http.StatusOK, gin.H{"ok": false, "error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"ok": true})
|
||||
@@ -91,7 +91,7 @@ func aria2StatsHandler(svc *service.Container) gin.HandlerFunc {
|
||||
}
|
||||
out, err := svc.DownloadClients.Aria2GlobalStats(c.Request.Context(), clientID)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, out)
|
||||
|
||||
Reference in New Issue
Block a user