fix(channels): handle RowsAffected errors in Update and Delete #1907

Merged
agent-dev-a merged 1 commits from fix/channels-rowsaffected into main 2026-05-26 13:36:29 +00:00
+14 -2
View File
@@ -246,7 +246,13 @@ func (h *ChannelHandler) Update(c *gin.Context) {
return
}
if n, _ := result.RowsAffected(); n == 0 {
n, err := result.RowsAffected()
if err != nil {
log.Printf("Channel update RowsAffected error channel=%s workspace=%s: %v", channelID, workspaceID, err)
c.JSON(http.StatusInternalServerError, gin.H{"error": "update failed"})
return
}
if n == 0 {
c.JSON(http.StatusNotFound, gin.H{"error": "channel not found"})
return
}
@@ -271,7 +277,13 @@ func (h *ChannelHandler) Delete(c *gin.Context) {
return
}
if n, _ := result.RowsAffected(); n == 0 {
n, err := result.RowsAffected()
if err != nil {
log.Printf("Channel delete RowsAffected error channel=%s workspace=%s: %v", channelID, workspaceID, err)
c.JSON(http.StatusInternalServerError, gin.H{"error": "delete failed"})
return
}
if n == 0 {
c.JSON(http.StatusNotFound, gin.H{"error": "channel not found"})
return
}