diff options
author | Morgan Bazalgette <git@howl.moe> | 2018-01-10 22:34:17 +0100 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2018-01-10 23:34:17 +0200 |
commit | 65861900cda3bb6d9e2aa80b808b0000383c04b3 (patch) | |
tree | 8569d93b6ef092b30b35a4d4da906c6b6950e2ee /routers/repo/editor.go | |
parent | 45c264f681e3f7e1a22a191029836a690959aac3 (diff) | |
download | gitea-65861900cda3bb6d9e2aa80b808b0000383c04b3.tar.gz gitea-65861900cda3bb6d9e2aa80b808b0000383c04b3.zip |
Handle refactor (#3339)
* Replace all ctx.Handle with ctx.ServerError or ctx.NotFound
* Change Handle(403) to NotFound, avoid using macaron's NotFound
Diffstat (limited to 'routers/repo/editor.go')
-rw-r--r-- | routers/repo/editor.go | 20 |
1 files changed, 10 insertions, 10 deletions
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 } |