From 9e3c83372f19853ac1dc164e2fcf58d9779ac0f0 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 7 Apr 2017 16:00:25 -0400 Subject: api/repo: improve migration error handling --- routers/api/v1/repo/repo.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'routers/api/v1/repo/repo.go') 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 } -- cgit v1.2.3