1
1
mirror of https://github.com/go-gitea/gitea synced 2025-08-05 17:18:21 +00:00

Mark TemplateLoading error as "UnprocessableEntity" (#19445) (#19446)

* Mark TemplateLoading error as "UnprocessableEntity" (#19445)

- Backport #19445
  - Don't return Internal Server error if the user provide incorrect label template, instead return UnprocessableEntity.
  - Resolves #19399

- dep: upgrade: github.com/gogs/chardet
This commit is contained in:
Gusted
2022-04-22 19:07:57 +00:00
committed by GitHub
parent 1d665da32f
commit 1f0dca4614
3 changed files with 8 additions and 7 deletions

View File

@@ -160,7 +160,7 @@ func Search(ctx *context.APIContext) {
opts.Collaborate = util.OptionalBoolFalse
}
var mode = ctx.FormString("mode")
mode := ctx.FormString("mode")
switch mode {
case "source":
opts.Fork = util.OptionalBoolFalse
@@ -186,9 +186,9 @@ func Search(ctx *context.APIContext) {
opts.IsPrivate = util.OptionalBoolOf(ctx.FormBool("is_private"))
}
var sortMode = ctx.FormString("sort")
sortMode := ctx.FormString("sort")
if len(sortMode) > 0 {
var sortOrder = ctx.FormString("order")
sortOrder := ctx.FormString("order")
if len(sortOrder) == 0 {
sortOrder = "asc"
}
@@ -264,7 +264,8 @@ func CreateUserRepo(ctx *context.APIContext, owner *user_model.User, opt api.Cre
if repo_model.IsErrRepoAlreadyExist(err) {
ctx.Error(http.StatusConflict, "", "The repository with the same name already exists.")
} else if db.IsErrNameReserved(err) ||
db.IsErrNamePatternNotAllowed(err) {
db.IsErrNamePatternNotAllowed(err) ||
models.IsErrIssueLabelTemplateLoad(err) {
ctx.Error(http.StatusUnprocessableEntity, "", err)
} else {
ctx.Error(http.StatusInternalServerError, "CreateRepository", err)