1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Refactor error system (#33626)

This commit is contained in:
wxiaoguang
2025-02-18 04:41:03 +08:00
committed by GitHub
parent 7df09e31fa
commit 15e020eec8
75 changed files with 703 additions and 693 deletions

View File

@@ -56,7 +56,7 @@ func CreateOrUpdateSecret(ctx *context.APIContext) {
} else if errors.Is(err, util.ErrNotExist) {
ctx.APIError(http.StatusNotFound, err)
} else {
ctx.APIError(http.StatusInternalServerError, err)
ctx.APIErrorInternal(err)
}
return
}
@@ -98,7 +98,7 @@ func DeleteSecret(ctx *context.APIContext) {
} else if errors.Is(err, util.ErrNotExist) {
ctx.APIError(http.StatusNotFound, err)
} else {
ctx.APIError(http.StatusInternalServerError, err)
ctx.APIErrorInternal(err)
}
return
}
@@ -145,7 +145,7 @@ func CreateVariable(ctx *context.APIContext) {
Name: variableName,
})
if err != nil && !errors.Is(err, util.ErrNotExist) {
ctx.APIError(http.StatusInternalServerError, err)
ctx.APIErrorInternal(err)
return
}
if v != nil && v.ID > 0 {
@@ -157,7 +157,7 @@ func CreateVariable(ctx *context.APIContext) {
if errors.Is(err, util.ErrInvalidArgument) {
ctx.APIError(http.StatusBadRequest, err)
} else {
ctx.APIError(http.StatusInternalServerError, err)
ctx.APIErrorInternal(err)
}
return
}
@@ -204,7 +204,7 @@ func UpdateVariable(ctx *context.APIContext) {
if errors.Is(err, util.ErrNotExist) {
ctx.APIError(http.StatusNotFound, err)
} else {
ctx.APIError(http.StatusInternalServerError, err)
ctx.APIErrorInternal(err)
}
return
}
@@ -220,7 +220,7 @@ func UpdateVariable(ctx *context.APIContext) {
if errors.Is(err, util.ErrInvalidArgument) {
ctx.APIError(http.StatusBadRequest, err)
} else {
ctx.APIError(http.StatusInternalServerError, err)
ctx.APIErrorInternal(err)
}
return
}
@@ -257,7 +257,7 @@ func DeleteVariable(ctx *context.APIContext) {
} else if errors.Is(err, util.ErrNotExist) {
ctx.APIError(http.StatusNotFound, err)
} else {
ctx.APIError(http.StatusInternalServerError, err)
ctx.APIErrorInternal(err)
}
return
}
@@ -294,7 +294,7 @@ func GetVariable(ctx *context.APIContext) {
if errors.Is(err, util.ErrNotExist) {
ctx.APIError(http.StatusNotFound, err)
} else {
ctx.APIError(http.StatusInternalServerError, err)
ctx.APIErrorInternal(err)
}
return
}
@@ -338,7 +338,7 @@ func ListVariables(ctx *context.APIContext) {
ListOptions: utils.GetListOptions(ctx),
})
if err != nil {
ctx.APIError(http.StatusInternalServerError, err)
ctx.APIErrorInternal(err)
return
}