diff options
author | Unknwon <u@gogs.io> | 2017-04-07 16:00:25 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2017-04-07 16:00:25 -0400 |
commit | 9e3c83372f19853ac1dc164e2fcf58d9779ac0f0 (patch) | |
tree | 166972d800ff862afc91120889f0fe0c5fa45854 /routers | |
parent | 809db853fa3938885aae98b058ed524b6f4aef84 (diff) |
api/repo: improve migration error handling
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo/repo.go | 9 | ||||
-rw-r--r-- | routers/repo/repo.go | 2 |
2 files changed, 8 insertions, 3 deletions
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index fdb3e7a5..f86905d4 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -250,7 +250,7 @@ func Migrate(ctx *context.APIContext, f form.MigrateRepo) { case addrErr.IsPermissionDenied: ctx.Error(422, "", "You are not allowed to import local repositories") case addrErr.IsInvalidPath: - ctx.Error(422, "", "Invalid local path, it does not exist or not a directory.") + ctx.Error(422, "", "Invalid local path, it does not exist or not a directory") default: ctx.Error(500, "ParseRemoteAddr", "Unknown error type (ErrInvalidCloneAddr): "+err.Error()) } @@ -273,7 +273,12 @@ func Migrate(ctx *context.APIContext, f form.MigrateRepo) { log.Error(2, "DeleteRepository: %v", errDelete) } } - ctx.Error(500, "MigrateRepository", models.HandleMirrorCredentials(err.Error(), true)) + + if errors.IsReachLimitOfRepo(err) { + ctx.Error(422, "", err) + } else { + ctx.Error(500, "MigrateRepository", models.HandleMirrorCredentials(err.Error(), true)) + } return } diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 3f99f53c..a50fc937 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -87,7 +87,7 @@ func Create(ctx *context.Context) { func handleCreateError(ctx *context.Context, owner *models.User, err error, name, tpl string, form interface{}) { switch { - case models.IsErrReachLimitOfRepo(err): + case errors.IsReachLimitOfRepo(err): ctx.RenderWithErr(ctx.Tr("repo.form.reach_limit_of_creation", owner.RepoCreationNum()), tpl, form) case models.IsErrRepoAlreadyExist(err): ctx.Data["Err_RepoName"] = true |