From 65861900cda3bb6d9e2aa80b808b0000383c04b3 Mon Sep 17 00:00:00 2001 From: Morgan Bazalgette Date: Wed, 10 Jan 2018 22:34:17 +0100 Subject: Handle refactor (#3339) * Replace all ctx.Handle with ctx.ServerError or ctx.NotFound * Change Handle(403) to NotFound, avoid using macaron's NotFound --- routers/repo/editor.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'routers/repo/editor.go') diff --git a/routers/repo/editor.go b/routers/repo/editor.go index 82b04a84d2..6c6bf304fc 100644 --- a/routers/repo/editor.go +++ b/routers/repo/editor.go @@ -73,19 +73,19 @@ func editFile(ctx *context.Context, isNewFile bool) { // No way to edit a directory online. if entry.IsDir() { - ctx.Handle(404, "entry.IsDir", nil) + ctx.NotFound("entry.IsDir", nil) return } blob := entry.Blob() if blob.Size() >= setting.UI.MaxDisplayFileSize { - ctx.Handle(404, "blob.Size", err) + ctx.NotFound("blob.Size", err) return } dataRc, err := blob.Data() if err != nil { - ctx.Handle(404, "blob.Data", err) + ctx.NotFound("blob.Data", err) return } @@ -98,7 +98,7 @@ func editFile(ctx *context.Context, isNewFile bool) { // Only text file are editable online. if !base.IsTextFile(buf) { - ctx.Handle(404, "base.IsTextFile", nil) + ctx.NotFound("base.IsTextFile", nil) return } @@ -214,7 +214,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo break } - ctx.Handle(500, "Repo.Commit.GetTreeEntryByPath", err) + ctx.ServerError("Repo.Commit.GetTreeEntryByPath", err) return } if index != len(treeNames)-1 { @@ -244,14 +244,14 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo ctx.Data["Err_TreePath"] = true ctx.RenderWithErr(ctx.Tr("repo.editor.file_editing_no_longer_exists", oldTreePath), tplEditFile, &form) } else { - ctx.Handle(500, "GetTreeEntryByPath", err) + ctx.ServerError("GetTreeEntryByPath", err) } return } if lastCommit != ctx.Repo.CommitID { files, err := ctx.Repo.Commit.GetFilesChangedSinceCommit(lastCommit) if err != nil { - ctx.Handle(500, "GetFilesChangedSinceCommit", err) + ctx.ServerError("GetFilesChangedSinceCommit", err) return } @@ -269,7 +269,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo entry, err := ctx.Repo.Commit.GetTreeEntryByPath(form.TreePath) if err != nil { if !git.IsErrNotExist(err) { - ctx.Handle(500, "GetTreeEntryByPath", err) + ctx.ServerError("GetTreeEntryByPath", err) return } } @@ -422,7 +422,7 @@ func DeleteFilePost(ctx *context.Context, form auth.DeleteRepoFileForm) { TreePath: ctx.Repo.TreePath, Message: message, }); err != nil { - ctx.Handle(500, "DeleteRepoFile", err) + ctx.ServerError("DeleteRepoFile", err) return } @@ -521,7 +521,7 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) { break } - ctx.Handle(500, "Repo.Commit.GetTreeEntryByPath", err) + ctx.ServerError("Repo.Commit.GetTreeEntryByPath", err) return } -- cgit v1.2.3