mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-01 12:06:38 +08:00
fix: additional HTTP status code and error handling corrections
- createBackupHandler: 200 → 201 Created - addDownloadHandler: 200 → 201 Created, service errors → 500 - createAssistantSessionHandler: 200 → 201 Created - writeUserMutationError: default error → 500 (was 400) - resetUserPasswordHandler: service errors → 500, success → 204 NoContent - createLibraryHandler: service errors → 500 (was 400) Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
@@ -144,10 +144,10 @@ func resetUserPasswordHandler(svc *service.Container) gin.HandlerFunc {
|
||||
return
|
||||
}
|
||||
if err := svc.Auth.ResetPassword(c.Request.Context(), c.Param("id"), req.Password); 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, gin.H{"ok": true})
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ func writeUserMutationError(c *gin.Context, err error) {
|
||||
case errors.Is(err, service.ErrUserLimitReached):
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "user limit reached: maximum 20 users"})
|
||||
default:
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user