Skip to content

Commit ec491b0

Browse files
committed
api/repo: fix nil error panic
1 parent f191bff commit ec491b0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

routers/api/v1/repo/repo.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR
167167
} else {
168168
if repo != nil {
169169
if err = models.DeleteRepository(ctx.User.ID, repo.ID); err != nil {
170-
log.Error(4, "DeleteRepository: %v", err)
170+
log.Error(2, "DeleteRepository: %v", err)
171171
}
172172
}
173173
ctx.Error(500, "CreateRepository", err)
@@ -221,7 +221,7 @@ func Migrate(ctx *context.APIContext, f form.MigrateRepo) {
221221
}
222222
return
223223
} else if !org.IsOrganization() {
224-
ctx.Error(403, "", err)
224+
ctx.Error(403, "", "Given user is not an organization")
225225
return
226226
}
227227
ctxUser = org
@@ -235,7 +235,7 @@ func Migrate(ctx *context.APIContext, f form.MigrateRepo) {
235235
if ctxUser.IsOrganization() && !ctx.User.IsAdmin {
236236
// Check ownership of organization.
237237
if !ctxUser.IsOwnedBy(ctx.User.ID) {
238-
ctx.Error(403, "", "Given user is not owner of organization.")
238+
ctx.Error(403, "", "Given user is not owner of organization")
239239
return
240240
}
241241
}
@@ -248,7 +248,7 @@ func Migrate(ctx *context.APIContext, f form.MigrateRepo) {
248248
case addrErr.IsURLError:
249249
ctx.Error(422, "", err)
250250
case addrErr.IsPermissionDenied:
251-
ctx.Error(422, "", "You are not allowed to import local repositories.")
251+
ctx.Error(422, "", "You are not allowed to import local repositories")
252252
case addrErr.IsInvalidPath:
253253
ctx.Error(422, "", "Invalid local path, it does not exist or not a directory.")
254254
default:
@@ -270,7 +270,7 @@ func Migrate(ctx *context.APIContext, f form.MigrateRepo) {
270270
if err != nil {
271271
if repo != nil {
272272
if errDelete := models.DeleteRepository(ctxUser.ID, repo.ID); errDelete != nil {
273-
log.Error(4, "DeleteRepository: %v", errDelete)
273+
log.Error(2, "DeleteRepository: %v", errDelete)
274274
}
275275
}
276276
ctx.Error(500, "MigrateRepository", models.HandleMirrorCredentials(err.Error(), true))

0 commit comments

Comments
 (0)