Refactor error system (#33610)

This commit is contained in:
wxiaoguang 2025-02-17 14:13:17 +08:00 committed by GitHub
parent 69de5a65c2
commit f35850f48e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
184 changed files with 2100 additions and 2106 deletions

View file

@ -56,7 +56,7 @@ func ListTopics(ctx *context.APIContext) {
topics, total, err := db.FindAndCount[repo_model.Topic](ctx, opts)
if err != nil {
ctx.InternalServerError(err)
ctx.APIErrorInternal(err)
return
}
@ -124,7 +124,7 @@ func UpdateTopics(ctx *context.APIContext) {
err := repo_model.SaveTopics(ctx, ctx.Repo.Repository.ID, validTopics...)
if err != nil {
log.Error("SaveTopics failed: %v", err)
ctx.InternalServerError(err)
ctx.APIErrorInternal(err)
return
}
@ -178,7 +178,7 @@ func AddTopic(ctx *context.APIContext) {
})
if err != nil {
log.Error("CountTopics failed: %v", err)
ctx.InternalServerError(err)
ctx.APIErrorInternal(err)
return
}
if count >= 25 {
@ -191,7 +191,7 @@ func AddTopic(ctx *context.APIContext) {
_, err = repo_model.AddTopic(ctx, ctx.Repo.Repository.ID, topicName)
if err != nil {
log.Error("AddTopic failed: %v", err)
ctx.InternalServerError(err)
ctx.APIErrorInternal(err)
return
}
@ -242,12 +242,12 @@ func DeleteTopic(ctx *context.APIContext) {
topic, err := repo_model.DeleteTopic(ctx, ctx.Repo.Repository.ID, topicName)
if err != nil {
log.Error("DeleteTopic failed: %v", err)
ctx.InternalServerError(err)
ctx.APIErrorInternal(err)
return
}
if topic == nil {
ctx.NotFound()
ctx.APIErrorNotFound()
return
}
@ -290,7 +290,7 @@ func TopicSearch(ctx *context.APIContext) {
topics, total, err := db.FindAndCount[repo_model.Topic](ctx, opts)
if err != nil {
ctx.InternalServerError(err)
ctx.APIErrorInternal(err)
return
}