feat: 完善api错误提示

This commit is contained in:
tbphp
2025-07-03 21:33:16 +08:00
parent 745c646530
commit c0594d068e
10 changed files with 127 additions and 220 deletions

View File

@@ -7,6 +7,7 @@ import (
"github.com/gin-gonic/gin"
"gpt-load/internal/db"
app_errors "gpt-load/internal/errors"
"gpt-load/internal/models"
"gpt-load/internal/response"
)
@@ -66,7 +67,7 @@ func GetLogs(c *gin.Context) {
query.Count(&total)
err := query.Order("timestamp desc").Offset(offset).Limit(size).Find(&logs).Error
if err != nil {
response.Error(c, http.StatusInternalServerError, "Failed to get logs")
response.Error(c, app_errors.ParseDBError(err))
return
}
@@ -76,4 +77,4 @@ func GetLogs(c *gin.Context) {
"size": size,
"data": logs,
})
}
}