1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Refactor error system (#33610)

This commit is contained in:
wxiaoguang
2025-02-17 14:13:17 +08:00
committed by GitHub
parent 69de5a65c2
commit f35850f48e
184 changed files with 2100 additions and 2106 deletions

View File

@@ -45,18 +45,18 @@ type Workflow struct {
// MustEnableActions check if actions are enabled in settings
func MustEnableActions(ctx *context.Context) {
if !setting.Actions.Enabled {
ctx.NotFound("MustEnableActions", nil)
ctx.NotFound(nil)
return
}
if unit.TypeActions.UnitGlobalDisabled() {
ctx.NotFound("MustEnableActions", nil)
ctx.NotFound(nil)
return
}
if ctx.Repo.Repository != nil {
if !ctx.Repo.CanRead(unit.TypeActions) {
ctx.NotFound("MustEnableActions", nil)
ctx.NotFound(nil)
return
}
}
@@ -88,7 +88,7 @@ func List(ctx *context.Context) {
func WorkflowDispatchInputs(ctx *context.Context) {
ref := ctx.FormString("ref")
if ref == "" {
ctx.NotFound("WorkflowDispatchInputs: no ref", nil)
ctx.NotFound(nil)
return
}
// get target commit of run from specified ref

View File

@@ -277,7 +277,7 @@ func ViewPost(ctx *context_module.Context) {
if task != nil {
steps, logs, err := convertToViewModel(ctx, req.LogCursors, task)
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return
}
resp.State.CurrentJob.Steps = append(resp.State.CurrentJob.Steps, steps...)
@@ -381,7 +381,7 @@ func Rerun(ctx *context_module.Context) {
run, err := actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex)
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return
}
@@ -399,7 +399,7 @@ func Rerun(ctx *context_module.Context) {
run.Started = 0
run.Stopped = 0
if err := actions_model.UpdateRun(ctx, run, "started", "stopped", "previous_duration"); err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return
}
}
@@ -414,7 +414,7 @@ func Rerun(ctx *context_module.Context) {
// if the job has needs, it should be set to "blocked" status to wait for other jobs
shouldBlock := len(j.Needs) > 0
if err := rerunJob(ctx, j, shouldBlock); err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return
}
}
@@ -428,7 +428,7 @@ func Rerun(ctx *context_module.Context) {
// jobs other than the specified one should be set to "blocked" status
shouldBlock := j.JobID != job.JobID
if err := rerunJob(ctx, j, shouldBlock); err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return
}
}
@@ -470,29 +470,29 @@ func Logs(ctx *context_module.Context) {
return
}
if job.TaskID == 0 {
ctx.Error(http.StatusNotFound, "job is not started")
ctx.HTTPError(http.StatusNotFound, "job is not started")
return
}
err := job.LoadRun(ctx)
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return
}
task, err := actions_model.GetTaskByID(ctx, job.TaskID)
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return
}
if task.LogExpired {
ctx.Error(http.StatusNotFound, "logs have been cleaned up")
ctx.HTTPError(http.StatusNotFound, "logs have been cleaned up")
return
}
reader, err := actions.OpenLogs(ctx, task.LogInStorage, task.LogFilename)
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return
}
defer reader.Close()
@@ -542,7 +542,7 @@ func Cancel(ctx *context_module.Context) {
}
return nil
}); err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return
}
@@ -578,7 +578,7 @@ func Approve(ctx *context_module.Context) {
}
return nil
}); err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return
}
@@ -594,20 +594,20 @@ func getRunJobs(ctx *context_module.Context, runIndex, jobIndex int64) (*actions
run, err := actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex)
if err != nil {
if errors.Is(err, util.ErrNotExist) {
ctx.Error(http.StatusNotFound, err.Error())
ctx.HTTPError(http.StatusNotFound, err.Error())
return nil, nil
}
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return nil, nil
}
run.Repo = ctx.Repo.Repository
jobs, err := actions_model.GetRunJobsByRunID(ctx, run.ID)
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return nil, nil
}
if len(jobs) == 0 {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return nil, nil
}
@@ -633,7 +633,7 @@ func ArtifactsDeleteView(ctx *context_module.Context) {
return
}
if err = actions_model.SetArtifactNeedDelete(ctx, run.ID, artifactName); err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return
}
ctx.JSON(http.StatusOK, struct{}{})
@@ -646,10 +646,10 @@ func ArtifactsDownloadView(ctx *context_module.Context) {
run, err := actions_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex)
if err != nil {
if errors.Is(err, util.ErrNotExist) {
ctx.Error(http.StatusNotFound, err.Error())
ctx.HTTPError(http.StatusNotFound, err.Error())
return
}
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return
}
@@ -658,18 +658,18 @@ func ArtifactsDownloadView(ctx *context_module.Context) {
ArtifactName: artifactName,
})
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return
}
if len(artifacts) == 0 {
ctx.Error(http.StatusNotFound, "artifact not found")
ctx.HTTPError(http.StatusNotFound, "artifact not found")
return
}
// if artifacts status is not uploaded-confirmed, treat it as not found
for _, art := range artifacts {
if art.Status != actions_model.ArtifactStatusUploadConfirmed {
ctx.Error(http.StatusNotFound, "artifact not found")
ctx.HTTPError(http.StatusNotFound, "artifact not found")
return
}
}
@@ -679,7 +679,7 @@ func ArtifactsDownloadView(ctx *context_module.Context) {
if len(artifacts) == 1 && actions.IsArtifactV4(artifacts[0]) {
err := actions.DownloadArtifactV4(ctx.Base, artifacts[0])
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return
}
return
@@ -692,7 +692,7 @@ func ArtifactsDownloadView(ctx *context_module.Context) {
for _, art := range artifacts {
f, err := storage.ActionsArtifacts.Open(art.StoragePath)
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return
}
@@ -700,7 +700,7 @@ func ArtifactsDownloadView(ctx *context_module.Context) {
if art.ContentEncoding == "gzip" {
r, err = gzip.NewReader(f)
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return
}
} else {
@@ -710,11 +710,11 @@ func ArtifactsDownloadView(ctx *context_module.Context) {
w, err := writer.Create(art.ArtifactPath)
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return
}
if _, err := io.Copy(w, r); err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return
}
}

View File

@@ -34,13 +34,13 @@ func UploadReleaseAttachment(ctx *context.Context) {
// UploadAttachment response for uploading attachments
func uploadAttachment(ctx *context.Context, repoID int64, allowedTypes string) {
if !setting.Attachment.Enabled {
ctx.Error(http.StatusNotFound, "attachment is not enabled")
ctx.HTTPError(http.StatusNotFound, "attachment is not enabled")
return
}
file, header, err := ctx.Req.FormFile("file")
if err != nil {
ctx.Error(http.StatusInternalServerError, fmt.Sprintf("FormFile: %v", err))
ctx.HTTPError(http.StatusInternalServerError, fmt.Sprintf("FormFile: %v", err))
return
}
defer file.Close()
@@ -52,10 +52,10 @@ func uploadAttachment(ctx *context.Context, repoID int64, allowedTypes string) {
})
if err != nil {
if upload.IsErrFileTypeForbidden(err) {
ctx.Error(http.StatusBadRequest, err.Error())
ctx.HTTPError(http.StatusBadRequest, err.Error())
return
}
ctx.Error(http.StatusInternalServerError, fmt.Sprintf("NewAttachment: %v", err))
ctx.HTTPError(http.StatusInternalServerError, fmt.Sprintf("NewAttachment: %v", err))
return
}
@@ -70,16 +70,16 @@ func DeleteAttachment(ctx *context.Context) {
file := ctx.FormString("file")
attach, err := repo_model.GetAttachmentByUUID(ctx, file)
if err != nil {
ctx.Error(http.StatusBadRequest, err.Error())
ctx.HTTPError(http.StatusBadRequest, err.Error())
return
}
if !ctx.IsSigned || (ctx.Doer.ID != attach.UploaderID) {
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return
}
err = repo_model.DeleteAttachment(ctx, attach, true)
if err != nil {
ctx.Error(http.StatusInternalServerError, fmt.Sprintf("DeleteAttachment: %v", err))
ctx.HTTPError(http.StatusInternalServerError, fmt.Sprintf("DeleteAttachment: %v", err))
return
}
ctx.JSON(http.StatusOK, map[string]string{
@@ -92,7 +92,7 @@ func ServeAttachment(ctx *context.Context, uuid string) {
attach, err := repo_model.GetAttachmentByUUID(ctx, uuid)
if err != nil {
if repo_model.IsErrAttachmentNotExist(err) {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
} else {
ctx.ServerError("GetAttachmentByUUID", err)
}
@@ -107,17 +107,17 @@ func ServeAttachment(ctx *context.Context, uuid string) {
if repository == nil { // If not linked
if !(ctx.IsSigned && attach.UploaderID == ctx.Doer.ID) { // We block if not the uploader
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return
}
} else { // If we have the repository we check access
perm, err := access_model.GetUserRepoPermission(ctx, repository, ctx.Doer)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetUserRepoPermission", err.Error())
ctx.HTTPError(http.StatusInternalServerError, "GetUserRepoPermission", err.Error())
return
}
if !perm.CanRead(unitType) {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return
}
}

View File

@@ -42,7 +42,7 @@ type blameRow struct {
func RefBlame(ctx *context.Context) {
fileName := ctx.Repo.TreePath
if len(fileName) == 0 {
ctx.NotFound("Blame FileName", nil)
ctx.NotFound(nil)
return
}
@@ -99,7 +99,7 @@ func RefBlame(ctx *context.Context) {
ctx.Data["NumLines"], err = blob.GetBlobLineCount()
if err != nil {
ctx.NotFound("GetBlobLineCount", err)
ctx.NotFound(err)
return
}
@@ -107,7 +107,7 @@ func RefBlame(ctx *context.Context) {
result, err := performBlame(ctx, ctx.Repo.Repository.RepoPath(), ctx.Repo.Commit, fileName, bypassBlameIgnore)
if err != nil {
ctx.NotFound("CreateBlameReader", err)
ctx.NotFound(err)
return
}
@@ -221,7 +221,7 @@ func processBlameParts(ctx *context.Context, blameParts []*git.BlamePart) map[st
commit, err = ctx.Repo.GitRepo.GetCommit(sha)
if err != nil {
if git.IsErrNotExist(err) {
ctx.NotFound("Repo.GitRepo.GetCommit", err)
ctx.NotFound(err)
} else {
ctx.ServerError("Repo.GitRepo.GetCommit", err)
}

View File

@@ -178,7 +178,7 @@ func jsonRedirectBranches(ctx *context.Context) {
func CreateBranch(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.NewBranchForm)
if !ctx.Repo.CanCreateBranch() {
ctx.NotFound("CreateBranch", nil)
ctx.NotFound(nil)
return
}

View File

@@ -28,7 +28,7 @@ func CherryPick(ctx *context.Context) {
cherryPickCommit, err := ctx.Repo.GitRepo.GetCommit(ctx.PathParam("sha"))
if err != nil {
if git.IsErrNotExist(err) {
ctx.NotFound("Missing Commit", err)
ctx.NotFound(err)
return
}
ctx.ServerError("GetCommit", err)
@@ -148,7 +148,7 @@ func CherryPickPost(ctx *context.Context) {
if form.Revert {
if err := git.GetReverseRawDiff(ctx, ctx.Repo.Repository.RepoPath(), sha, buf); err != nil {
if git.IsErrNotExist(err) {
ctx.NotFound("GetRawDiff", errors.New("commit "+ctx.PathParam("sha")+" does not exist."))
ctx.NotFound(errors.New("commit " + ctx.PathParam("sha") + " does not exist."))
return
}
ctx.ServerError("GetRawDiff", err)
@@ -157,7 +157,7 @@ func CherryPickPost(ctx *context.Context) {
} else {
if err := git.GetRawDiff(ctx.Repo.GitRepo, sha, git.RawDiffType("patch"), buf); err != nil {
if git.IsErrNotExist(err) {
ctx.NotFound("GetRawDiff", errors.New("commit "+ctx.PathParam("sha")+" does not exist."))
ctx.NotFound(errors.New("commit " + ctx.PathParam("sha") + " does not exist."))
return
}
ctx.ServerError("GetRawDiff", err)

View File

@@ -59,7 +59,7 @@ func RefCommits(ctx *context.Context) {
func Commits(ctx *context.Context) {
ctx.Data["PageIsCommits"] = true
if ctx.Repo.Commit == nil {
ctx.NotFound("Commit not found", nil)
ctx.NotFound(nil)
return
}
ctx.Data["PageIsViewCode"] = true
@@ -226,7 +226,7 @@ func FileHistory(ctx *context.Context) {
ctx.ServerError("FileCommitsCount", err)
return
} else if commitsCount == 0 {
ctx.NotFound("FileCommitsCount", nil)
ctx.NotFound(nil)
return
}
@@ -297,7 +297,7 @@ func Diff(ctx *context.Context) {
commit, err := gitRepo.GetCommit(commitID)
if err != nil {
if git.IsErrNotExist(err) {
ctx.NotFound("Repo.GitRepo.GetCommit", err)
ctx.NotFound(err)
} else {
ctx.ServerError("Repo.GitRepo.GetCommit", err)
}
@@ -324,7 +324,7 @@ func Diff(ctx *context.Context) {
FileOnly: fileOnly,
}, files...)
if err != nil {
ctx.NotFound("GetDiff", err)
ctx.NotFound(err)
return
}
@@ -332,7 +332,7 @@ func Diff(ctx *context.Context) {
for i := 0; i < commit.ParentCount(); i++ {
sha, err := commit.ParentID(i)
if err != nil {
ctx.NotFound("repo.Diff", err)
ctx.NotFound(err)
return
}
parents[i] = sha.String()
@@ -347,7 +347,7 @@ func Diff(ctx *context.Context) {
if commit.ParentCount() > 0 {
parentCommit, err = gitRepo.GetCommit(parents[0])
if err != nil {
ctx.NotFound("GetParentCommit", err)
ctx.NotFound(err)
return
}
}
@@ -421,8 +421,7 @@ func RawDiff(ctx *context.Context) {
ctx.Resp,
); err != nil {
if git.IsErrNotExist(err) {
ctx.NotFound("GetRawDiff",
errors.New("commit "+ctx.PathParam("sha")+" does not exist."))
ctx.NotFound(errors.New("commit " + ctx.PathParam("sha") + " does not exist."))
return
}
ctx.ServerError("GetRawDiff", err)

View File

@@ -258,7 +258,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
ci.HeadUser, err = user_model.GetUserByName(ctx, headInfos[0])
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.NotFound("GetUserByName", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("GetUserByName", err)
}
@@ -273,7 +273,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
ci.HeadRepo, err = repo_model.GetRepositoryByOwnerAndName(ctx, headInfosSplit[0], headInfosSplit[1])
if err != nil {
if repo_model.IsErrRepoNotExist(err) {
ctx.NotFound("GetRepositoryByOwnerAndName", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("GetRepositoryByOwnerAndName", err)
}
@@ -281,7 +281,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
}
if err := ci.HeadRepo.LoadOwner(ctx); err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.NotFound("GetUserByName", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("GetUserByName", err)
}
@@ -292,7 +292,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
isSameRepo = ci.HeadRepo.ID == ctx.Repo.Repository.ID
}
} else {
ctx.NotFound("CompareAndPullRequest", nil)
ctx.NotFound(nil)
return nil
}
ctx.Data["HeadUser"] = ci.HeadUser
@@ -318,7 +318,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
}
return nil
} else {
ctx.NotFound("IsRefExist", nil)
ctx.NotFound(nil)
return nil
}
}
@@ -408,7 +408,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
}
defer ci.HeadGitRepo.Close()
} else {
ctx.NotFound("ParseCompareInfo", nil)
ctx.NotFound(nil)
return nil
}
@@ -430,7 +430,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
baseRepo,
permBase)
}
ctx.NotFound("ParseCompareInfo", nil)
ctx.NotFound(nil)
return nil
}
@@ -449,7 +449,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
ci.HeadRepo,
permHead)
}
ctx.NotFound("ParseCompareInfo", nil)
ctx.NotFound(nil)
return nil
}
ctx.Data["CanWriteToHeadRepo"] = permHead.CanWrite(unit.TypeCode)
@@ -513,7 +513,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
ctx.Data["HeadBranch"] = ci.HeadBranch
headIsCommit = true
} else {
ctx.NotFound("IsRefExist", nil)
ctx.NotFound(nil)
return nil
}
}
@@ -533,7 +533,7 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
baseRepo,
permBase)
}
ctx.NotFound("ParseCompareInfo", nil)
ctx.NotFound(nil)
return nil
}
@@ -880,7 +880,7 @@ func ExcerptBlob(ctx *context.Context) {
chunkSize := gitdiff.BlobExcerptChunkSize
commit, err := gitRepo.GetCommit(commitID)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetCommit")
ctx.HTTPError(http.StatusInternalServerError, "GetCommit")
return
}
section := &gitdiff.DiffSection{
@@ -909,7 +909,7 @@ func ExcerptBlob(ctx *context.Context) {
idxRight = lastRight
}
if err != nil {
ctx.Error(http.StatusInternalServerError, "getExcerptLines")
ctx.HTTPError(http.StatusInternalServerError, "getExcerptLines")
return
}
if idxRight > lastRight {

View File

@@ -85,7 +85,7 @@ func getBlobForEntry(ctx *context.Context) (*git.Blob, *time.Time) {
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(ctx.Repo.TreePath)
if err != nil {
if git.IsErrNotExist(err) {
ctx.NotFound("GetTreeEntryByPath", err)
ctx.NotFound(err)
} else {
ctx.ServerError("GetTreeEntryByPath", err)
}
@@ -93,7 +93,7 @@ func getBlobForEntry(ctx *context.Context) (*git.Blob, *time.Time) {
}
if entry.IsDir() || entry.IsSubModule() {
ctx.NotFound("getBlobForEntry", nil)
ctx.NotFound(nil)
return nil, nil
}
@@ -136,7 +136,7 @@ func DownloadByID(ctx *context.Context) {
blob, err := ctx.Repo.GitRepo.GetBlob(ctx.PathParam("sha"))
if err != nil {
if git.IsErrNotExist(err) {
ctx.NotFound("GetBlob", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("GetBlob", err)
}
@@ -152,7 +152,7 @@ func DownloadByIDOrLFS(ctx *context.Context) {
blob, err := ctx.Repo.GitRepo.GetBlob(ctx.PathParam("sha"))
if err != nil {
if git.IsErrNotExist(err) {
ctx.NotFound("GetBlob", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("GetBlob", err)
}

View File

@@ -141,19 +141,19 @@ func editFile(ctx *context.Context, isNewFile bool) {
// No way to edit a directory online.
if entry.IsDir() {
ctx.NotFound("entry.IsDir", nil)
ctx.NotFound(nil)
return
}
blob := entry.Blob()
if blob.Size() >= setting.UI.MaxDisplayFileSize {
ctx.NotFound("blob.Size", err)
ctx.NotFound(err)
return
}
dataRc, err := blob.DataAsync()
if err != nil {
ctx.NotFound("blob.Data", err)
ctx.NotFound(err)
return
}
@@ -168,7 +168,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
// Only some file types are editable online as text.
if !typesniffer.DetectContentType(buf).IsRepresentableAsText() {
ctx.NotFound("typesniffer.IsRepresentableAsText", nil)
ctx.NotFound(nil)
return
}
@@ -324,7 +324,7 @@ func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile b
ctx.RenderWithErr(ctx.Tr("repo.editor.filename_is_invalid", fileErr.Path), tplEditFile, &form)
}
} else {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
}
} else if files_service.IsErrRepoFileAlreadyExists(err) {
ctx.Data["Err_TreePath"] = true
@@ -334,7 +334,7 @@ func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile b
if branchErr, ok := err.(git.ErrBranchNotExist); ok {
ctx.RenderWithErr(ctx.Tr("repo.editor.branch_does_not_exist", branchErr.Name), tplEditFile, &form)
} else {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
}
} else if git_model.IsErrBranchAlreadyExists(err) {
// For when a user specifies a new branch that already exists
@@ -342,7 +342,7 @@ func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile b
if branchErr, ok := err.(git_model.ErrBranchAlreadyExists); ok {
ctx.RenderWithErr(ctx.Tr("repo.editor.branch_already_exists", branchErr.BranchName), tplEditFile, &form)
} else {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
}
} else if files_service.IsErrCommitIDDoesNotMatch(err) {
ctx.RenderWithErr(ctx.Tr("repo.editor.commit_id_not_matching"), tplEditFile, &form)
@@ -404,22 +404,22 @@ func DiffPreviewPost(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.EditPreviewDiffForm)
treePath := cleanUploadFileName(ctx.Repo.TreePath)
if len(treePath) == 0 {
ctx.Error(http.StatusInternalServerError, "file name to diff is invalid")
ctx.HTTPError(http.StatusInternalServerError, "file name to diff is invalid")
return
}
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(treePath)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetTreeEntryByPath: "+err.Error())
ctx.HTTPError(http.StatusInternalServerError, "GetTreeEntryByPath: "+err.Error())
return
} else if entry.IsDir() {
ctx.Error(http.StatusUnprocessableEntity)
ctx.HTTPError(http.StatusUnprocessableEntity)
return
}
diff, err := files_service.GetDiffPreview(ctx, ctx.Repo.Repository, ctx.Repo.BranchName, treePath, form.Content)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetDiffPreview: "+err.Error())
ctx.HTTPError(http.StatusInternalServerError, "GetDiffPreview: "+err.Error())
return
}
@@ -545,14 +545,14 @@ func DeleteFilePost(ctx *context.Context) {
if branchErr, ok := err.(git.ErrBranchNotExist); ok {
ctx.RenderWithErr(ctx.Tr("repo.editor.branch_does_not_exist", branchErr.Name), tplDeleteFile, &form)
} else {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
}
} else if git_model.IsErrBranchAlreadyExists(err) {
// For when a user specifies a new branch that already exists
if branchErr, ok := err.(git_model.ErrBranchAlreadyExists); ok {
ctx.RenderWithErr(ctx.Tr("repo.editor.branch_already_exists", branchErr.BranchName), tplDeleteFile, &form)
} else {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
}
} else if files_service.IsErrCommitIDDoesNotMatch(err) || git.IsErrPushOutOfDate(err) {
ctx.RenderWithErr(ctx.Tr("repo.editor.file_changed_while_deleting", ctx.Repo.RepoLink+"/compare/"+util.PathEscapeSegments(form.LastCommit)+"..."+util.PathEscapeSegments(ctx.Repo.CommitID)), tplDeleteFile, &form)
@@ -751,7 +751,7 @@ func UploadFilePost(ctx *context.Context) {
case git.EntryModeBlob:
ctx.RenderWithErr(ctx.Tr("repo.editor.directory_is_a_file", fileErr.Path), tplUploadFile, &form)
default:
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
}
} else if files_service.IsErrRepoFileAlreadyExists(err) {
ctx.Data["Err_TreePath"] = true
@@ -815,7 +815,7 @@ func cleanUploadFileName(name string) string {
func UploadFileToServer(ctx *context.Context) {
file, header, err := ctx.Req.FormFile("file")
if err != nil {
ctx.Error(http.StatusInternalServerError, fmt.Sprintf("FormFile: %v", err))
ctx.HTTPError(http.StatusInternalServerError, fmt.Sprintf("FormFile: %v", err))
return
}
defer file.Close()
@@ -828,19 +828,19 @@ func UploadFileToServer(ctx *context.Context) {
err = upload.Verify(buf, header.Filename, setting.Repository.Upload.AllowedTypes)
if err != nil {
ctx.Error(http.StatusBadRequest, err.Error())
ctx.HTTPError(http.StatusBadRequest, err.Error())
return
}
name := cleanUploadFileName(header.Filename)
if len(name) == 0 {
ctx.Error(http.StatusInternalServerError, "Upload file name is invalid")
ctx.HTTPError(http.StatusInternalServerError, "Upload file name is invalid")
return
}
upload, err := repo_model.NewUpload(ctx, name, buf, file)
if err != nil {
ctx.Error(http.StatusInternalServerError, fmt.Sprintf("NewUpload: %v", err))
ctx.HTTPError(http.StatusInternalServerError, fmt.Sprintf("NewUpload: %v", err))
return
}
@@ -859,7 +859,7 @@ func RemoveUploadFileFromServer(ctx *context.Context) {
}
if err := repo_model.DeleteUploadByUUID(ctx, form.File); err != nil {
ctx.Error(http.StatusInternalServerError, fmt.Sprintf("DeleteUploadByUUID: %v", err))
ctx.HTTPError(http.StatusInternalServerError, fmt.Sprintf("DeleteUploadByUUID: %v", err))
return
}

View File

@@ -37,7 +37,7 @@ func getForkRepository(ctx *context.Context) *repo_model.Repository {
if forkRepo.IsEmpty {
log.Trace("Empty repository %-v", forkRepo)
ctx.NotFound("getForkRepository", nil)
ctx.NotFound(nil)
return nil
}
@@ -189,7 +189,7 @@ func ForkPost(ctx *context.Context) {
ctx.ServerError("CanCreateOrgRepo", err)
return
} else if !isAllowedToFork {
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return
}
}

View File

@@ -147,7 +147,7 @@ func httpBase(ctx *context.Context) *serviceHandler {
if !ctx.IsSigned {
// TODO: support digit auth - which would be Authorization header with digit
ctx.Resp.Header().Set("WWW-Authenticate", `Basic realm="Gitea"`)
ctx.Error(http.StatusUnauthorized)
ctx.HTTPError(http.StatusUnauthorized)
return nil
}

View File

@@ -12,7 +12,7 @@ func HandleGitError(ctx *context.Context, msg string, err error) {
if git.IsErrNotExist(err) {
ctx.Data["NotFoundPrompt"] = ctx.Locale.Tr("repo.tree_path_not_found", ctx.Repo.TreePath, ctx.Repo.RefTypeNameSubURL())
ctx.Data["NotFoundGoBackURL"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL()
ctx.NotFound(msg, err)
ctx.NotFound(err)
} else {
ctx.ServerError(msg, err)
}

View File

@@ -91,7 +91,7 @@ func MustAllowUserComment(ctx *context.Context) {
func MustEnableIssues(ctx *context.Context) {
if !ctx.Repo.CanRead(unit.TypeIssues) &&
!ctx.Repo.CanRead(unit.TypeExternalTracker) {
ctx.NotFound("MustEnableIssues", nil)
ctx.NotFound(nil)
return
}
@@ -105,7 +105,7 @@ func MustEnableIssues(ctx *context.Context) {
// MustAllowPulls check if repository enable pull requests and user have right to do that
func MustAllowPulls(ctx *context.Context) {
if !ctx.Repo.Repository.CanEnablePulls() || !ctx.Repo.CanRead(unit.TypePullRequests) {
ctx.NotFound("MustAllowPulls", nil)
ctx.NotFound(nil)
return
}
@@ -201,7 +201,7 @@ func GetActionIssue(ctx *context.Context) *issues_model.Issue {
func checkIssueRights(ctx *context.Context, issue *issues_model.Issue) {
if issue.IsPull && !ctx.Repo.CanRead(unit.TypePullRequests) ||
!issue.IsPull && !ctx.Repo.CanRead(unit.TypeIssues) {
ctx.NotFound("IssueOrPullRequestUnitNotAllowed", nil)
ctx.NotFound(nil)
}
}
@@ -229,11 +229,11 @@ func getActionIssues(ctx *context.Context) issues_model.IssueList {
prUnitEnabled := ctx.Repo.CanRead(unit.TypePullRequests)
for _, issue := range issues {
if issue.RepoID != ctx.Repo.Repository.ID {
ctx.NotFound("some issue's RepoID is incorrect", errors.New("some issue's RepoID is incorrect"))
ctx.NotFound(errors.New("some issue's RepoID is incorrect"))
return nil
}
if issue.IsPull && !prUnitEnabled || !issue.IsPull && !issueUnitEnabled {
ctx.NotFound("IssueOrPullRequestUnitNotAllowed", nil)
ctx.NotFound(nil)
return nil
}
if err = issue.LoadAttributes(ctx); err != nil {
@@ -249,9 +249,9 @@ func GetIssueInfo(ctx *context.Context) {
issue, err := issues_model.GetIssueWithAttrsByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
} else {
ctx.Error(http.StatusInternalServerError, "GetIssueByIndex", err.Error())
ctx.HTTPError(http.StatusInternalServerError, "GetIssueByIndex", err.Error())
}
return
}
@@ -259,13 +259,13 @@ func GetIssueInfo(ctx *context.Context) {
if issue.IsPull {
// Need to check if Pulls are enabled and we can read Pulls
if !ctx.Repo.Repository.CanEnablePulls() || !ctx.Repo.CanRead(unit.TypePullRequests) {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return
}
} else {
// Need to check if Issues are enabled and we can read Issues
if !ctx.Repo.CanRead(unit.TypeIssues) {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return
}
}
@@ -284,13 +284,13 @@ func UpdateIssueTitle(ctx *context.Context) {
}
if !ctx.IsSigned || (!issue.IsPoster(ctx.Doer.ID) && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) {
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return
}
title := ctx.FormTrim("title")
if len(title) == 0 {
ctx.Error(http.StatusNoContent)
ctx.HTTPError(http.StatusNoContent)
return
}
@@ -312,7 +312,7 @@ func UpdateIssueRef(ctx *context.Context) {
}
if !ctx.IsSigned || (!issue.IsPoster(ctx.Doer.ID) && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) || issue.IsPull {
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return
}
@@ -336,7 +336,7 @@ func UpdateIssueContent(ctx *context.Context) {
}
if !ctx.IsSigned || (ctx.Doer.ID != issue.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) {
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return
}
@@ -382,21 +382,21 @@ func UpdateIssueDeadline(ctx *context.Context) {
issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound("GetIssueByIndex", err)
ctx.NotFound(err)
} else {
ctx.Error(http.StatusInternalServerError, "GetIssueByIndex", err.Error())
ctx.HTTPError(http.StatusInternalServerError, "GetIssueByIndex", err.Error())
}
return
}
if !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) {
ctx.Error(http.StatusForbidden, "", "Not repo writer")
ctx.HTTPError(http.StatusForbidden, "", "Not repo writer")
return
}
deadlineUnix, _ := common.ParseDeadlineDateToEndOfDay(ctx.FormString("deadline"))
if err := issues_model.UpdateIssueDeadline(ctx, issue, deadlineUnix, ctx.Doer); err != nil {
ctx.Error(http.StatusInternalServerError, "UpdateIssueDeadline", err.Error())
ctx.HTTPError(http.StatusInternalServerError, "UpdateIssueDeadline", err.Error())
return
}
@@ -497,7 +497,7 @@ func ChangeIssueReaction(ctx *context.Context) {
}
}
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return
}
@@ -540,7 +540,7 @@ func ChangeIssueReaction(ctx *context.Context) {
log.Trace("Reaction for issue removed: %d/%d", ctx.Repo.Repository.ID, issue.ID)
default:
ctx.NotFound(fmt.Sprintf("Unknown action %s", ctx.PathParam("action")), nil)
ctx.NotFound(nil)
return
}

View File

@@ -53,7 +53,7 @@ func NewComment(ctx *context.Context) {
}
}
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return
}
@@ -224,17 +224,17 @@ func UpdateCommentContent(ctx *context.Context) {
}
if comment.Issue.RepoID != ctx.Repo.Repository.ID {
ctx.NotFound("CompareRepoID", issues_model.ErrCommentNotExist{})
ctx.NotFound(issues_model.ErrCommentNotExist{})
return
}
if !ctx.IsSigned || (ctx.Doer.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) {
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return
}
if !comment.Type.HasContentSupport() {
ctx.Error(http.StatusNoContent)
ctx.HTTPError(http.StatusNoContent)
return
}
@@ -302,15 +302,15 @@ func DeleteComment(ctx *context.Context) {
}
if comment.Issue.RepoID != ctx.Repo.Repository.ID {
ctx.NotFound("CompareRepoID", issues_model.ErrCommentNotExist{})
ctx.NotFound(issues_model.ErrCommentNotExist{})
return
}
if !ctx.IsSigned || (ctx.Doer.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) {
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return
} else if !comment.Type.HasContentSupport() {
ctx.Error(http.StatusNoContent)
ctx.HTTPError(http.StatusNoContent)
return
}
@@ -337,7 +337,7 @@ func ChangeCommentReaction(ctx *context.Context) {
}
if comment.Issue.RepoID != ctx.Repo.Repository.ID {
ctx.NotFound("CompareRepoID", issues_model.ErrCommentNotExist{})
ctx.NotFound(issues_model.ErrCommentNotExist{})
return
}
@@ -360,12 +360,12 @@ func ChangeCommentReaction(ctx *context.Context) {
}
}
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return
}
if !comment.Type.HasContentSupport() {
ctx.Error(http.StatusNoContent)
ctx.HTTPError(http.StatusNoContent)
return
}
@@ -403,7 +403,7 @@ func ChangeCommentReaction(ctx *context.Context) {
log.Trace("Reaction for comment removed: %d/%d/%d", ctx.Repo.Repository.ID, comment.Issue.ID, comment.ID)
default:
ctx.NotFound(fmt.Sprintf("Unknown action %s", ctx.PathParam("action")), nil)
ctx.NotFound(nil)
return
}
@@ -442,12 +442,12 @@ func GetCommentAttachments(ctx *context.Context) {
}
if comment.Issue.RepoID != ctx.Repo.Repository.ID {
ctx.NotFound("CompareRepoID", issues_model.ErrCommentNotExist{})
ctx.NotFound(issues_model.ErrCommentNotExist{})
return
}
if !ctx.Repo.Permission.CanReadIssuesOrPulls(comment.Issue.IsPull) {
ctx.NotFound("CanReadIssuesOrPulls", issues_model.ErrCommentNotExist{})
ctx.NotFound(issues_model.ErrCommentNotExist{})
return
}

View File

@@ -186,7 +186,7 @@ func SoftDeleteContentHistory(ctx *context.Context) {
return
}
if ctx.Doer == nil {
ctx.NotFound("Require SignIn", nil)
ctx.NotFound(nil)
return
}
@@ -202,12 +202,12 @@ func SoftDeleteContentHistory(ctx *context.Context) {
return
}
if history.IssueID != issue.ID {
ctx.NotFound("CompareRepoID", issues_model.ErrCommentNotExist{})
ctx.NotFound(issues_model.ErrCommentNotExist{})
return
}
if commentID != 0 {
if history.CommentID != commentID {
ctx.NotFound("CompareCommentID", issues_model.ErrCommentNotExist{})
ctx.NotFound(issues_model.ErrCommentNotExist{})
return
}
@@ -216,7 +216,7 @@ func SoftDeleteContentHistory(ctx *context.Context) {
return
}
if comment.IssueID != issue.ID {
ctx.NotFound("CompareIssueID", issues_model.ErrCommentNotExist{})
ctx.NotFound(issues_model.ErrCommentNotExist{})
return
}
}

View File

@@ -23,7 +23,7 @@ func AddDependency(ctx *context.Context) {
// Check if the Repo is allowed to have dependencies
if !ctx.Repo.CanCreateIssueDependencies(ctx, ctx.Doer, issue.IsPull) {
ctx.Error(http.StatusForbidden, "CanCreateIssueDependencies")
ctx.HTTPError(http.StatusForbidden, "CanCreateIssueDependencies")
return
}
@@ -97,7 +97,7 @@ func RemoveDependency(ctx *context.Context) {
// Check if the Repo is allowed to have dependencies
if !ctx.Repo.CanCreateIssueDependencies(ctx, ctx.Doer, issue.IsPull) {
ctx.Error(http.StatusForbidden, "CanCreateIssueDependencies")
ctx.HTTPError(http.StatusForbidden, "CanCreateIssueDependencies")
return
}
@@ -119,7 +119,7 @@ func RemoveDependency(ctx *context.Context) {
case "blocking":
depType = issues_model.DependencyTypeBlocking
default:
ctx.Error(http.StatusBadRequest, "GetDependecyType")
ctx.HTTPError(http.StatusBadRequest, "GetDependecyType")
return
}

View File

@@ -131,7 +131,7 @@ func UpdateLabel(ctx *context.Context) {
if err != nil {
switch {
case issues_model.IsErrRepoLabelNotExist(err):
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
default:
ctx.ServerError("UpdateLabel", err)
}
@@ -180,7 +180,7 @@ func UpdateIssueLabel(ctx *context.Context) {
label, err := issues_model.GetLabelByID(ctx, ctx.FormInt64("id"))
if err != nil {
if issues_model.IsErrRepoLabelNotExist(err) {
ctx.Error(http.StatusNotFound, "GetLabelByID")
ctx.HTTPError(http.StatusNotFound, "GetLabelByID")
} else {
ctx.ServerError("GetLabelByID", err)
}
@@ -221,7 +221,7 @@ func UpdateIssueLabel(ctx *context.Context) {
}
default:
log.Warn("Unrecognized action: %s", action)
ctx.Error(http.StatusInternalServerError)
ctx.HTTPError(http.StatusInternalServerError)
return
}

View File

@@ -46,7 +46,7 @@ func retrieveProjectsForIssueList(ctx *context.Context, repo *repo_model.Reposit
func SearchIssues(ctx *context.Context) {
before, since, err := context.GetQueryBeforeSince(ctx.Base)
if err != nil {
ctx.Error(http.StatusUnprocessableEntity, err.Error())
ctx.HTTPError(http.StatusUnprocessableEntity, err.Error())
return
}
@@ -84,9 +84,9 @@ func SearchIssues(ctx *context.Context) {
owner, err := user_model.GetUserByName(ctx, ctx.FormString("owner"))
if err != nil {
if user_model.IsErrUserNotExist(err) {
ctx.Error(http.StatusBadRequest, "Owner not found", err.Error())
ctx.HTTPError(http.StatusBadRequest, "Owner not found", err.Error())
} else {
ctx.Error(http.StatusInternalServerError, "GetUserByName", err.Error())
ctx.HTTPError(http.StatusInternalServerError, "GetUserByName", err.Error())
}
return
}
@@ -97,15 +97,15 @@ func SearchIssues(ctx *context.Context) {
}
if ctx.FormString("team") != "" {
if ctx.FormString("owner") == "" {
ctx.Error(http.StatusBadRequest, "", "Owner organisation is required for filtering on team")
ctx.HTTPError(http.StatusBadRequest, "", "Owner organisation is required for filtering on team")
return
}
team, err := organization.GetTeam(ctx, opts.OwnerID, ctx.FormString("team"))
if err != nil {
if organization.IsErrTeamNotExist(err) {
ctx.Error(http.StatusBadRequest, "Team not found", err.Error())
ctx.HTTPError(http.StatusBadRequest, "Team not found", err.Error())
} else {
ctx.Error(http.StatusInternalServerError, "GetUserByName", err.Error())
ctx.HTTPError(http.StatusInternalServerError, "GetUserByName", err.Error())
}
return
}
@@ -118,7 +118,7 @@ func SearchIssues(ctx *context.Context) {
}
repoIDs, _, err = repo_model.SearchRepositoryIDs(ctx, opts)
if err != nil {
ctx.Error(http.StatusInternalServerError, "SearchRepositoryIDs", err.Error())
ctx.HTTPError(http.StatusInternalServerError, "SearchRepositoryIDs", err.Error())
return
}
if len(repoIDs) == 0 {
@@ -149,7 +149,7 @@ func SearchIssues(ctx *context.Context) {
}
includedAnyLabels, err = issues_model.GetLabelIDsByNames(ctx, includedLabelNames)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetLabelIDsByNames", err.Error())
ctx.HTTPError(http.StatusInternalServerError, "GetLabelIDsByNames", err.Error())
return
}
}
@@ -163,7 +163,7 @@ func SearchIssues(ctx *context.Context) {
}
includedMilestones, err = issues_model.GetMilestoneIDsByNames(ctx, includedMilestoneNames)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetMilestoneIDsByNames", err.Error())
ctx.HTTPError(http.StatusInternalServerError, "GetMilestoneIDsByNames", err.Error())
return
}
}
@@ -230,12 +230,12 @@ func SearchIssues(ctx *context.Context) {
ids, total, err := issue_indexer.SearchIssues(ctx, searchOpt)
if err != nil {
ctx.Error(http.StatusInternalServerError, "SearchIssues", err.Error())
ctx.HTTPError(http.StatusInternalServerError, "SearchIssues", err.Error())
return
}
issues, err := issues_model.GetIssuesByIDs(ctx, ids, true)
if err != nil {
ctx.Error(http.StatusInternalServerError, "FindIssuesByIDs", err.Error())
ctx.HTTPError(http.StatusInternalServerError, "FindIssuesByIDs", err.Error())
return
}
@@ -251,12 +251,12 @@ func getUserIDForFilter(ctx *context.Context, queryName string) int64 {
user, err := user_model.GetUserByName(ctx, userName)
if user_model.IsErrUserNotExist(err) {
ctx.NotFound("", err)
ctx.NotFound(err)
return 0
}
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return 0
}
@@ -269,7 +269,7 @@ func getUserIDForFilter(ctx *context.Context, queryName string) int64 {
func SearchRepoIssuesJSON(ctx *context.Context) {
before, since, err := context.GetQueryBeforeSince(ctx.Base)
if err != nil {
ctx.Error(http.StatusUnprocessableEntity, err.Error())
ctx.HTTPError(http.StatusUnprocessableEntity, err.Error())
return
}
@@ -299,7 +299,7 @@ func SearchRepoIssuesJSON(ctx *context.Context) {
continue
}
if !issues_model.IsErrMilestoneNotExist(err) {
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
return
}
id, err := strconv.ParseInt(part[i], 10, 64)
@@ -314,7 +314,7 @@ func SearchRepoIssuesJSON(ctx *context.Context) {
if issues_model.IsErrMilestoneNotExist(err) {
continue
}
ctx.Error(http.StatusInternalServerError, err.Error())
ctx.HTTPError(http.StatusInternalServerError, err.Error())
}
}
@@ -384,12 +384,12 @@ func SearchRepoIssuesJSON(ctx *context.Context) {
ids, total, err := issue_indexer.SearchIssues(ctx, searchOpt)
if err != nil {
ctx.Error(http.StatusInternalServerError, "SearchIssues", err.Error())
ctx.HTTPError(http.StatusInternalServerError, "SearchIssues", err.Error())
return
}
issues, err := issues_model.GetIssuesByIDs(ctx, ids, true)
if err != nil {
ctx.Error(http.StatusInternalServerError, "FindIssuesByIDs", err.Error())
ctx.HTTPError(http.StatusInternalServerError, "FindIssuesByIDs", err.Error())
return
}

View File

@@ -255,7 +255,7 @@ func ValidateRepoMetasForNewIssue(ctx *context.Context, form forms.CreateIssueFo
inputLabelIDs, _ := base.StringsToInt64s(strings.Split(form.LabelIDs, ","))
candidateLabels := toSet(pageMetaData.LabelsData.AllLabels, func(label *issues_model.Label) int64 { return label.ID })
if len(inputLabelIDs) > 0 && !candidateLabels.Contains(inputLabelIDs...) {
ctx.NotFound("", nil)
ctx.NotFound(nil)
return ret
}
pageMetaData.LabelsData.SetSelectedLabelIDs(inputLabelIDs)
@@ -263,7 +263,7 @@ func ValidateRepoMetasForNewIssue(ctx *context.Context, form forms.CreateIssueFo
allMilestones := append(slices.Clone(pageMetaData.MilestonesData.OpenMilestones), pageMetaData.MilestonesData.ClosedMilestones...)
candidateMilestones := toSet(allMilestones, func(milestone *issues_model.Milestone) int64 { return milestone.ID })
if form.MilestoneID > 0 && !candidateMilestones.Contains(form.MilestoneID) {
ctx.NotFound("", nil)
ctx.NotFound(nil)
return ret
}
pageMetaData.MilestonesData.SelectedMilestoneID = form.MilestoneID
@@ -271,7 +271,7 @@ func ValidateRepoMetasForNewIssue(ctx *context.Context, form forms.CreateIssueFo
allProjects := append(slices.Clone(pageMetaData.ProjectsData.OpenProjects), pageMetaData.ProjectsData.ClosedProjects...)
candidateProjects := toSet(allProjects, func(project *project_model.Project) int64 { return project.ID })
if form.ProjectID > 0 && !candidateProjects.Contains(form.ProjectID) {
ctx.NotFound("", nil)
ctx.NotFound(nil)
return ret
}
pageMetaData.ProjectsData.SelectedProjectID = form.ProjectID
@@ -304,14 +304,14 @@ func ValidateRepoMetasForNewIssue(ctx *context.Context, form forms.CreateIssueFo
if rID < 0 { // negative reviewIDs represent team requests
team, ok := teamReviewersMap[-rID]
if !ok {
ctx.NotFound("", nil)
ctx.NotFound(nil)
return ret
}
teamReviewers = append(teamReviewers, team)
} else {
user, ok := userReviewersMap[rID]
if !ok {
ctx.NotFound("", nil)
ctx.NotFound(nil)
return ret
}
reviewers = append(reviewers, user)
@@ -349,7 +349,7 @@ func NewIssuePost(ctx *context.Context) {
if projectID > 0 {
if !ctx.Repo.CanRead(unit.TypeProjects) {
// User must also be able to see the project.
ctx.Error(http.StatusBadRequest, "user hasn't permissions to read projects")
ctx.HTTPError(http.StatusBadRequest, "user hasn't permissions to read projects")
return
}
}
@@ -388,7 +388,7 @@ func NewIssuePost(ctx *context.Context) {
if err := issue_service.NewIssue(ctx, repo, issue, labelIDs, attachments, assigneeIDs, projectID); err != nil {
if repo_model.IsErrUserDoesNotHaveAccessToRepo(err) {
ctx.Error(http.StatusBadRequest, "UserDoesNotHaveAccessToRepo", err.Error())
ctx.HTTPError(http.StatusBadRequest, "UserDoesNotHaveAccessToRepo", err.Error())
} else if errors.Is(err, user_model.ErrBlockedUser) {
ctx.JSONError(ctx.Tr("repo.issues.new.blocked_user"))
} else {

View File

@@ -26,7 +26,7 @@ func IssueStopwatch(c *context.Context) {
}
if !c.Repo.CanUseTimetracker(c, issue, c.Doer) {
c.NotFound("CanUseTimetracker", nil)
c.NotFound(nil)
return
}
@@ -49,7 +49,7 @@ func CancelStopwatch(c *context.Context) {
return
}
if !c.Repo.CanUseTimetracker(c, issue, c.Doer) {
c.NotFound("CanUseTimetracker", nil)
c.NotFound(nil)
return
}

View File

@@ -25,7 +25,7 @@ func AddTimeManually(c *context.Context) {
return
}
if !c.Repo.CanUseTimetracker(c, issue, c.Doer) {
c.NotFound("CanUseTimetracker", nil)
c.NotFound(nil)
return
}
@@ -56,23 +56,23 @@ func DeleteTime(c *context.Context) {
return
}
if !c.Repo.CanUseTimetracker(c, issue, c.Doer) {
c.NotFound("CanUseTimetracker", nil)
c.NotFound(nil)
return
}
t, err := issues_model.GetTrackedTimeByID(c, c.PathParamInt64("timeid"))
if err != nil {
if db.IsErrNotExist(err) {
c.NotFound("time not found", err)
c.NotFound(err)
return
}
c.Error(http.StatusInternalServerError, "GetTrackedTimeByID", err.Error())
c.HTTPError(http.StatusInternalServerError, "GetTrackedTimeByID", err.Error())
return
}
// only OP or admin may delete
if !c.IsSigned || (!c.IsUserSiteAdmin() && c.Doer.ID != t.UserID) {
c.Error(http.StatusForbidden, "not allowed")
c.HTTPError(http.StatusForbidden, "not allowed")
return
}
@@ -92,7 +92,7 @@ func UpdateIssueTimeEstimate(ctx *context.Context) {
}
if !ctx.IsSigned || (!issue.IsPoster(ctx.Doer.ID) && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) {
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return
}

View File

@@ -297,7 +297,7 @@ func ViewIssue(ctx *context.Context) {
issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound("GetIssueByIndex", err)
ctx.NotFound(err)
} else {
ctx.ServerError("GetIssueByIndex", err)
}

View File

@@ -42,7 +42,7 @@ func IssueWatch(ctx *context.Context) {
log.Trace("Permission Denied: Not logged in")
}
}
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return
}

View File

@@ -35,7 +35,7 @@ const (
// Migrate render migration of repository page
func Migrate(ctx *context.Context) {
if setting.Repository.DisableMigrations {
ctx.Error(http.StatusForbidden, "Migrate: the site administrator has disabled migrations")
ctx.HTTPError(http.StatusForbidden, "Migrate: the site administrator has disabled migrations")
return
}
@@ -72,7 +72,7 @@ func Migrate(ctx *context.Context) {
func handleMigrateError(ctx *context.Context, owner *user_model.User, err error, name string, tpl templates.TplName, form *forms.MigrateRepoForm) {
if setting.Repository.DisableMigrations {
ctx.Error(http.StatusForbidden, "MigrateError: the site administrator has disabled migrations")
ctx.HTTPError(http.StatusForbidden, "MigrateError: the site administrator has disabled migrations")
return
}
@@ -152,12 +152,12 @@ func handleMigrateRemoteAddrError(ctx *context.Context, err error, tpl templates
func MigratePost(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.MigrateRepoForm)
if setting.Repository.DisableMigrations {
ctx.Error(http.StatusForbidden, "MigratePost: the site administrator has disabled migrations")
ctx.HTTPError(http.StatusForbidden, "MigratePost: the site administrator has disabled migrations")
return
}
if form.Mirror && setting.Mirror.DisableNewPull {
ctx.Error(http.StatusBadRequest, "MigratePost: the site administrator has disabled creation of new mirrors")
ctx.HTTPError(http.StatusBadRequest, "MigratePost: the site administrator has disabled creation of new mirrors")
return
}

View File

@@ -148,7 +148,7 @@ func EditMilestone(ctx *context.Context) {
m, err := issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("id"))
if err != nil {
if issues_model.IsErrMilestoneNotExist(err) {
ctx.NotFound("", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("GetMilestoneByRepoID", err)
}
@@ -184,7 +184,7 @@ func EditMilestonePost(ctx *context.Context) {
m, err := issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("id"))
if err != nil {
if issues_model.IsErrMilestoneNotExist(err) {
ctx.NotFound("", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("GetMilestoneByRepoID", err)
}
@@ -218,7 +218,7 @@ func ChangeMilestoneStatus(ctx *context.Context) {
if err := issues_model.ChangeMilestoneStatusByRepoIDAndID(ctx, ctx.Repo.Repository.ID, id, toClose); err != nil {
if issues_model.IsErrMilestoneNotExist(err) {
ctx.NotFound("", err)
ctx.NotFound(err)
} else {
ctx.ServerError("ChangeMilestoneStatusByIDAndRepoID", err)
}
@@ -245,7 +245,7 @@ func MilestoneIssuesAndPulls(ctx *context.Context) {
milestone, err := issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, milestoneID)
if err != nil {
if issues_model.IsErrMilestoneNotExist(err) {
ctx.NotFound("GetMilestoneByID", err)
ctx.NotFound(err)
return
}

View File

@@ -39,14 +39,14 @@ const (
// MustEnableRepoProjects check if repo projects are enabled in settings
func MustEnableRepoProjects(ctx *context.Context) {
if unit.TypeProjects.UnitGlobalDisabled() {
ctx.NotFound("EnableRepoProjects", nil)
ctx.NotFound(nil)
return
}
if ctx.Repo.Repository != nil {
projectsUnit := ctx.Repo.Repository.MustGetUnit(ctx, unit.TypeProjects)
if !ctx.Repo.CanRead(unit.TypeProjects) || !projectsUnit.ProjectsConfig().IsProjectsAllowed(repo_model.ProjectsModeRepo) {
ctx.NotFound("MustEnableRepoProjects", nil)
ctx.NotFound(nil)
return
}
}
@@ -194,14 +194,14 @@ func DeleteProject(ctx *context.Context) {
p, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("GetProjectByID", err)
}
return
}
if p.RepoID != ctx.Repo.Repository.ID {
ctx.NotFound("", nil)
ctx.NotFound(nil)
return
}
@@ -224,14 +224,14 @@ func RenderEditProject(ctx *context.Context) {
p, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("GetProjectByID", err)
}
return
}
if p.RepoID != ctx.Repo.Repository.ID {
ctx.NotFound("", nil)
ctx.NotFound(nil)
return
}
@@ -264,14 +264,14 @@ func EditProjectPost(ctx *context.Context) {
p, err := project_model.GetProjectByID(ctx, projectID)
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("GetProjectByID", err)
}
return
}
if p.RepoID != ctx.Repo.Repository.ID {
ctx.NotFound("", nil)
ctx.NotFound(nil)
return
}
@@ -296,14 +296,14 @@ func ViewProject(ctx *context.Context) {
project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("GetProjectByID", err)
}
return
}
if project.RepoID != ctx.Repo.Repository.ID {
ctx.NotFound("", nil)
ctx.NotFound(nil)
return
}
@@ -480,7 +480,7 @@ func DeleteProjectColumn(ctx *context.Context) {
project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("GetProjectByID", err)
}
@@ -527,7 +527,7 @@ func AddColumnToProjectPost(ctx *context.Context) {
project, err := project_model.GetProjectForRepoByID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("GetProjectByID", err)
}
@@ -565,7 +565,7 @@ func checkProjectColumnChangePermissions(ctx *context.Context) (*project_model.P
project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("GetProjectByID", err)
}
@@ -651,21 +651,21 @@ func MoveIssues(ctx *context.Context) {
project, err := project_model.GetProjectByID(ctx, ctx.PathParamInt64("id"))
if err != nil {
if project_model.IsErrProjectNotExist(err) {
ctx.NotFound("ProjectNotExist", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("GetProjectByID", err)
}
return
}
if project.RepoID != ctx.Repo.Repository.ID {
ctx.NotFound("InvalidRepoID", nil)
ctx.NotFound(nil)
return
}
column, err := project_model.GetColumn(ctx, ctx.PathParamInt64("columnID"))
if err != nil {
if project_model.IsErrProjectColumnNotExist(err) {
ctx.NotFound("ProjectColumnNotExist", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("GetProjectColumn", err)
}
@@ -673,7 +673,7 @@ func MoveIssues(ctx *context.Context) {
}
if column.ProjectID != project.ID {
ctx.NotFound("ColumnNotInProject", nil)
ctx.NotFound(nil)
return
}
@@ -698,7 +698,7 @@ func MoveIssues(ctx *context.Context) {
movedIssues, err := issues_model.GetIssuesByIDs(ctx, issueIDs)
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound("IssueNotExisting", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("GetIssueByID", err)
}

View File

@@ -81,7 +81,7 @@ func getRepository(ctx *context.Context, repoID int64) *repo_model.Repository {
repo, err := repo_model.GetRepositoryByID(ctx, repoID)
if err != nil {
if repo_model.IsErrRepoNotExist(err) {
ctx.NotFound("GetRepositoryByID", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("GetRepositoryByID", err)
}
@@ -101,7 +101,7 @@ func getRepository(ctx *context.Context, repoID int64) *repo_model.Repository {
unit.TypeCode,
ctx.Repo,
perm)
ctx.NotFound("getRepository", nil)
ctx.NotFound(nil)
return nil
}
return repo
@@ -111,7 +111,7 @@ func getPullInfo(ctx *context.Context) (issue *issues_model.Issue, ok bool) {
issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
if err != nil {
if issues_model.IsErrIssueNotExist(err) {
ctx.NotFound("GetIssueByIndex", err)
ctx.NotFound(err)
} else {
ctx.ServerError("GetIssueByIndex", err)
}
@@ -129,7 +129,7 @@ func getPullInfo(ctx *context.Context) (issue *issues_model.Issue, ok bool) {
ctx.Data["Issue"] = issue
if !issue.IsPull {
ctx.NotFound("ViewPullCommits", nil)
ctx.NotFound(nil)
return nil, false
}
@@ -190,7 +190,7 @@ func GetPullDiffStats(ctx *context.Context) {
mergeBaseCommitID := GetMergedBaseCommitID(ctx, issue)
if mergeBaseCommitID == "" {
ctx.NotFound("PullFiles", nil)
ctx.NotFound(nil)
return
}
@@ -624,7 +624,7 @@ func ViewPullCommits(ctx *context.Context) {
if ctx.Written() {
return
} else if prInfo == nil {
ctx.NotFound("ViewPullCommits", nil)
ctx.NotFound(nil)
return
}
@@ -672,7 +672,7 @@ func viewPullFiles(ctx *context.Context, specifiedStartCommit, specifiedEndCommi
if ctx.Written() {
return
} else if prInfo == nil {
ctx.NotFound("ViewPullFiles", nil)
ctx.NotFound(nil)
return
}
@@ -697,7 +697,7 @@ func viewPullFiles(ctx *context.Context, specifiedStartCommit, specifiedEndCommi
}
if !(foundStartCommit && foundEndCommit) {
ctx.NotFound("Given SHA1 not found for this PR", nil)
ctx.NotFound(nil)
return
}
}
@@ -935,11 +935,11 @@ func UpdatePullRequest(ctx *context.Context) {
return
}
if issue.IsClosed {
ctx.NotFound("MergePullRequest", nil)
ctx.NotFound(nil)
return
}
if issue.PullRequest.HasMerged {
ctx.NotFound("MergePullRequest", nil)
ctx.NotFound(nil)
return
}
@@ -1338,7 +1338,7 @@ func CompareAndPullRequestPost(ctx *context.Context) {
if err := pull_service.NewPullRequest(ctx, prOpts); err != nil {
switch {
case repo_model.IsErrUserDoesNotHaveAccessToRepo(err):
ctx.Error(http.StatusBadRequest, "UserDoesNotHaveAccessToRepo", err.Error())
ctx.HTTPError(http.StatusBadRequest, "UserDoesNotHaveAccessToRepo", err.Error())
case git.IsErrPushRejected(err):
pushrejErr := err.(*git.ErrPushRejected)
message := pushrejErr.Message
@@ -1409,7 +1409,7 @@ func CleanUpPullRequest(ctx *context.Context) {
// Don't cleanup unmerged and unclosed PRs and agit PRs
if !pr.HasMerged && !issue.IsClosed && pr.Flow != issues_model.PullRequestFlowGithub {
ctx.NotFound("CleanUpPullRequest", nil)
ctx.NotFound(nil)
return
}
@@ -1420,7 +1420,7 @@ func CleanUpPullRequest(ctx *context.Context) {
return
}
if exist {
ctx.NotFound("CleanUpPullRequest", nil)
ctx.NotFound(nil)
return
}
@@ -1429,7 +1429,7 @@ func CleanUpPullRequest(ctx *context.Context) {
return
} else if pr.HeadRepo == nil {
// Forked repository has already been deleted
ctx.NotFound("CleanUpPullRequest", nil)
ctx.NotFound(nil)
return
} else if err = pr.LoadBaseRepo(ctx); err != nil {
ctx.ServerError("LoadBaseRepo", err)
@@ -1441,7 +1441,7 @@ func CleanUpPullRequest(ctx *context.Context) {
if err := repo_service.CanDeleteBranch(ctx, pr.HeadRepo, pr.HeadBranch, ctx.Doer); err != nil {
if errors.Is(err, util.ErrPermissionDenied) {
ctx.NotFound("CanDeleteBranch", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("CanDeleteBranch", err)
}
@@ -1541,7 +1541,7 @@ func DownloadPullDiffOrPatch(ctx *context.Context, patch bool) {
pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
if err != nil {
if issues_model.IsErrPullRequestNotExist(err) {
ctx.NotFound("GetPullRequestByIndex", err)
ctx.NotFound(err)
} else {
ctx.ServerError("GetPullRequestByIndex", err)
}
@@ -1564,18 +1564,18 @@ func UpdatePullRequestTarget(ctx *context.Context) {
}
pr := issue.PullRequest
if !issue.IsPull {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return
}
if !ctx.IsSigned || (!issue.IsPoster(ctx.Doer.ID) && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) {
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return
}
targetBranch := ctx.FormTrim("target_branch")
if len(targetBranch) == 0 {
ctx.Error(http.StatusNoContent)
ctx.HTTPError(http.StatusNoContent)
return
}
@@ -1634,7 +1634,7 @@ func SetAllowEdits(ctx *context.Context) {
pr, err := issues_model.GetPullRequestByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
if err != nil {
if issues_model.IsErrPullRequestNotExist(err) {
ctx.NotFound("GetPullRequestByIndex", err)
ctx.NotFound(err)
} else {
ctx.ServerError("GetPullRequestByIndex", err)
}
@@ -1643,7 +1643,7 @@ func SetAllowEdits(ctx *context.Context) {
if err := pull_service.SetAllowEdits(ctx, ctx.Doer, pr, form.AllowMaintainerEdit); err != nil {
if errors.Is(err, pull_service.ErrUserHasNoPermissionForAction) {
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return
}
ctx.ServerError("SetAllowEdits", err)

View File

@@ -133,7 +133,7 @@ func UpdateResolveConversation(ctx *context.Context) {
}
if comment.Issue.RepoID != ctx.Repo.Repository.ID {
ctx.NotFound("comment's repoID is incorrect", errors.New("comment's repoID is incorrect"))
ctx.NotFound(errors.New("comment's repoID is incorrect"))
return
}
@@ -143,12 +143,12 @@ func UpdateResolveConversation(ctx *context.Context) {
return
}
if !permResult {
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return
}
if !comment.Issue.IsPull {
ctx.Error(http.StatusBadRequest)
ctx.HTTPError(http.StatusBadRequest)
return
}
@@ -159,7 +159,7 @@ func UpdateResolveConversation(ctx *context.Context) {
return
}
} else {
ctx.Error(http.StatusBadRequest)
ctx.HTTPError(http.StatusBadRequest)
return
}
@@ -214,7 +214,7 @@ func renderConversation(ctx *context.Context, comment *issues_model.Comment, ori
} else if origin == "timeline" {
ctx.HTML(http.StatusOK, tplTimelineConversation)
} else {
ctx.Error(http.StatusBadRequest, "Unknown origin: "+origin)
ctx.HTTPError(http.StatusBadRequest, "Unknown origin: "+origin)
}
}

View File

@@ -285,7 +285,7 @@ func SingleRelease(ctx *context.Context) {
return
}
if len(releases) != 1 {
ctx.NotFound("SingleRelease", err)
ctx.NotFound(err)
return
}
@@ -311,7 +311,7 @@ func LatestRelease(ctx *context.Context) {
release, err := repo_model.GetLatestReleaseByRepoID(ctx, ctx.Repo.Repository.ID)
if err != nil {
if repo_model.IsErrReleaseNotExist(err) {
ctx.NotFound("LatestRelease", err)
ctx.NotFound(err)
return
}
ctx.ServerError("GetLatestReleaseByRepoID", err)
@@ -525,7 +525,7 @@ func EditRelease(ctx *context.Context) {
rel, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, tagName)
if err != nil {
if repo_model.IsErrReleaseNotExist(err) {
ctx.NotFound("GetRelease", err)
ctx.NotFound(err)
} else {
ctx.ServerError("GetRelease", err)
}
@@ -568,14 +568,14 @@ func EditReleasePost(ctx *context.Context) {
rel, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, tagName)
if err != nil {
if repo_model.IsErrReleaseNotExist(err) {
ctx.NotFound("GetRelease", err)
ctx.NotFound(err)
} else {
ctx.ServerError("GetRelease", err)
}
return
}
if rel.IsTag {
ctx.NotFound("GetRelease", err)
ctx.NotFound(err)
return
}
ctx.Data["tag_name"] = rel.TagName
@@ -639,7 +639,7 @@ func deleteReleaseOrTag(ctx *context.Context, isDelTag bool) {
rel, err := repo_model.GetReleaseForRepoByID(ctx, ctx.Repo.Repository.ID, ctx.FormInt64("id"))
if err != nil {
if repo_model.IsErrReleaseNotExist(err) {
ctx.NotFound("GetReleaseForRepoByID", err)
ctx.NotFound(err)
} else {
ctx.Flash.Error("DeleteReleaseByID: " + err.Error())
redirect()

View File

@@ -30,7 +30,7 @@ func RenderFile(ctx *context.Context) {
}
if err != nil {
if git.IsErrNotExist(err) {
ctx.NotFound("GetBlobByPath", err)
ctx.NotFound(err)
} else {
ctx.ServerError("GetBlobByPath", err)
}

View File

@@ -45,14 +45,14 @@ const (
// MustBeNotEmpty render when a repo is a empty git dir
func MustBeNotEmpty(ctx *context.Context) {
if ctx.Repo.Repository.IsEmpty {
ctx.NotFound("MustBeNotEmpty", nil)
ctx.NotFound(nil)
}
}
// MustBeEditable check that repo can be edited
func MustBeEditable(ctx *context.Context) {
if !ctx.Repo.Repository.CanEnableEditor() {
ctx.NotFound("", nil)
ctx.NotFound(nil)
return
}
}
@@ -60,7 +60,7 @@ func MustBeEditable(ctx *context.Context) {
// MustBeAbleToUpload check that repo can be uploaded to
func MustBeAbleToUpload(ctx *context.Context) {
if !setting.Repository.Upload.Enabled {
ctx.NotFound("", nil)
ctx.NotFound(nil)
}
}
@@ -116,7 +116,7 @@ func checkContextUser(ctx *context.Context, uid int64) *user_model.User {
// Check ownership of organization.
if !org.IsOrganization() {
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return nil
}
if !ctx.Doer.IsAdmin {
@@ -125,7 +125,7 @@ func checkContextUser(ctx *context.Context, uid int64) *user_model.User {
ctx.ServerError("CanCreateOrgRepo", err)
return nil
} else if !canCreate {
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return nil
}
} else {
@@ -308,7 +308,7 @@ func handleActionError(ctx *context.Context, err error) {
if errors.Is(err, user_model.ErrBlockedUser) {
ctx.Flash.Error(ctx.Tr("repo.action.blocked_user"))
} else if errors.Is(err, util.ErrPermissionDenied) {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
} else {
ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.PathParam("action")), err)
}
@@ -335,7 +335,7 @@ func RedirectDownload(ctx *context.Context) {
release := releases[0]
att, err := repo_model.GetAttachmentByReleaseIDFileName(ctx, release.ID, fileName)
if err != nil {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return
}
if att != nil {
@@ -347,12 +347,12 @@ func RedirectDownload(ctx *context.Context) {
// We only fetch the latest release if the tag is "latest" and no release with the tag "latest" exists
release, err := repo_model.GetLatestReleaseByRepoID(ctx, ctx.Repo.Repository.ID)
if err != nil {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return
}
att, err := repo_model.GetAttachmentByReleaseIDFileName(ctx, release.ID, fileName)
if err != nil {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return
}
if att != nil {
@@ -360,7 +360,7 @@ func RedirectDownload(ctx *context.Context) {
return
}
}
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
}
// Download an archive of a repository
@@ -368,9 +368,9 @@ func Download(ctx *context.Context) {
aReq, err := archiver_service.NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, ctx.PathParam("*"))
if err != nil {
if errors.Is(err, archiver_service.ErrUnknownArchiveFormat{}) {
ctx.Error(http.StatusBadRequest, err.Error())
ctx.HTTPError(http.StatusBadRequest, err.Error())
} else if errors.Is(err, archiver_service.RepoRefNotFoundError{}) {
ctx.Error(http.StatusNotFound, err.Error())
ctx.HTTPError(http.StatusNotFound, err.Error())
} else {
ctx.ServerError("archiver_service.NewRequest", err)
}
@@ -425,11 +425,11 @@ func download(ctx *context.Context, archiveName string, archiver *repo_model.Rep
func InitiateDownload(ctx *context.Context) {
aReq, err := archiver_service.NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, ctx.PathParam("*"))
if err != nil {
ctx.Error(http.StatusBadRequest, "invalid archive request")
ctx.HTTPError(http.StatusBadRequest, "invalid archive request")
return
}
if aReq == nil {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return
}
@@ -501,7 +501,7 @@ func SearchRepo(ctx *context.Context) {
opts.Collaborate = optional.Some(true)
case "":
default:
ctx.Error(http.StatusUnprocessableEntity, fmt.Sprintf("Invalid search mode: \"%s\"", mode))
ctx.HTTPError(http.StatusUnprocessableEntity, fmt.Sprintf("Invalid search mode: \"%s\"", mode))
return
}
@@ -523,11 +523,11 @@ func SearchRepo(ctx *context.Context) {
if orderBy, ok := searchModeMap[sortMode]; ok {
opts.OrderBy = orderBy
} else {
ctx.Error(http.StatusUnprocessableEntity, fmt.Sprintf("Invalid sort mode: \"%s\"", sortMode))
ctx.HTTPError(http.StatusUnprocessableEntity, fmt.Sprintf("Invalid sort mode: \"%s\"", sortMode))
return
}
} else {
ctx.Error(http.StatusUnprocessableEntity, fmt.Sprintf("Invalid sort order: \"%s\"", sortOrder))
ctx.HTTPError(http.StatusUnprocessableEntity, fmt.Sprintf("Invalid sort order: \"%s\"", sortOrder))
return
}
}

View File

@@ -49,6 +49,6 @@ func SetDefaultBranchPost(ctx *context.Context) {
ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success"))
ctx.Redirect(setting.AppSubURL + ctx.Req.URL.EscapedPath())
default:
ctx.NotFound("", nil)
ctx.NotFound(nil)
}
}

View File

@@ -34,7 +34,7 @@ func GitHooksEdit(ctx *context.Context) {
hook, err := ctx.Repo.GitRepo.GetHook(name)
if err != nil {
if err == git.ErrNotValidHook {
ctx.NotFound("GetHook", err)
ctx.NotFound(err)
} else {
ctx.ServerError("GetHook", err)
}
@@ -50,7 +50,7 @@ func GitHooksEditPost(ctx *context.Context) {
hook, err := ctx.Repo.GitRepo.GetHook(name)
if err != nil {
if err == git.ErrNotValidHook {
ctx.NotFound("GetHook", err)
ctx.NotFound(err)
} else {
ctx.ServerError("GetHook", err)
}

View File

@@ -41,7 +41,7 @@ const (
// LFSFiles shows a repository's LFS files
func LFSFiles(ctx *context.Context) {
if !setting.LFS.StartServer {
ctx.NotFound("LFSFiles", nil)
ctx.NotFound(nil)
return
}
page := ctx.FormInt("page")
@@ -71,7 +71,7 @@ func LFSFiles(ctx *context.Context) {
// LFSLocks shows a repository's LFS locks
func LFSLocks(ctx *context.Context) {
if !setting.LFS.StartServer {
ctx.NotFound("LFSLocks", nil)
ctx.NotFound(nil)
return
}
ctx.Data["LFSFilesLink"] = ctx.Repo.RepoLink + "/settings/lfs"
@@ -197,7 +197,7 @@ func LFSLocks(ctx *context.Context) {
// LFSLockFile locks a file
func LFSLockFile(ctx *context.Context) {
if !setting.LFS.StartServer {
ctx.NotFound("LFSLocks", nil)
ctx.NotFound(nil)
return
}
originalPath := ctx.FormString("path")
@@ -238,7 +238,7 @@ func LFSLockFile(ctx *context.Context) {
// LFSUnlock forcibly unlocks an LFS lock
func LFSUnlock(ctx *context.Context) {
if !setting.LFS.StartServer {
ctx.NotFound("LFSUnlock", nil)
ctx.NotFound(nil)
return
}
_, err := git_model.DeleteLFSLockByID(ctx, ctx.PathParamInt64("lid"), ctx.Repo.Repository, ctx.Doer, true)
@@ -252,7 +252,7 @@ func LFSUnlock(ctx *context.Context) {
// LFSFileGet serves a single LFS file
func LFSFileGet(ctx *context.Context) {
if !setting.LFS.StartServer {
ctx.NotFound("LFSFileGet", nil)
ctx.NotFound(nil)
return
}
ctx.Data["LFSFilesLink"] = ctx.Repo.RepoLink + "/settings/lfs"
@@ -260,7 +260,7 @@ func LFSFileGet(ctx *context.Context) {
p := lfs.Pointer{Oid: oid}
if !p.IsValid() {
ctx.NotFound("LFSFileGet", nil)
ctx.NotFound(nil)
return
}
@@ -269,7 +269,7 @@ func LFSFileGet(ctx *context.Context) {
meta, err := git_model.GetLFSMetaObjectByOid(ctx, ctx.Repo.Repository.ID, oid)
if err != nil {
if err == git_model.ErrLFSObjectNotExist {
ctx.NotFound("LFSFileGet", nil)
ctx.NotFound(nil)
return
}
ctx.ServerError("LFSFileGet", err)
@@ -350,13 +350,13 @@ func LFSFileGet(ctx *context.Context) {
// LFSDelete disassociates the provided oid from the repository and if the lfs file is no longer associated with any repositories - deletes it
func LFSDelete(ctx *context.Context) {
if !setting.LFS.StartServer {
ctx.NotFound("LFSDelete", nil)
ctx.NotFound(nil)
return
}
oid := ctx.PathParam("oid")
p := lfs.Pointer{Oid: oid}
if !p.IsValid() {
ctx.NotFound("LFSDelete", nil)
ctx.NotFound(nil)
return
}
@@ -381,13 +381,13 @@ func LFSDelete(ctx *context.Context) {
// LFSFileFind guesses a sha for the provided oid (or uses the provided sha) and then finds the commits that contain this sha
func LFSFileFind(ctx *context.Context) {
if !setting.LFS.StartServer {
ctx.NotFound("LFSFind", nil)
ctx.NotFound(nil)
return
}
oid := ctx.FormString("oid")
size := ctx.FormInt64("size")
if len(oid) == 0 || size == 0 {
ctx.NotFound("LFSFind", nil)
ctx.NotFound(nil)
return
}
sha := ctx.FormString("sha")
@@ -421,7 +421,7 @@ func LFSFileFind(ctx *context.Context) {
// LFSPointerFiles will search the repository for pointer files and report which are missing LFS files in the content store
func LFSPointerFiles(ctx *context.Context) {
if !setting.LFS.StartServer {
ctx.NotFound("LFSFileGet", nil)
ctx.NotFound(nil)
return
}
ctx.Data["PageIsSettingsLFS"] = true
@@ -532,7 +532,7 @@ func LFSPointerFiles(ctx *context.Context) {
// LFSAutoAssociate auto associates accessible lfs files
func LFSAutoAssociate(ctx *context.Context) {
if !setting.LFS.StartServer {
ctx.NotFound("LFSAutoAssociate", nil)
ctx.NotFound(nil)
return
}
oids := ctx.FormStrings("oid")

View File

@@ -340,7 +340,7 @@ func RenameBranchPost(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.RenameBranchForm)
if !ctx.Repo.CanCreateBranch() {
ctx.NotFound("RenameBranch", nil)
ctx.NotFound(nil)
return
}

View File

@@ -183,7 +183,7 @@ func selectProtectedTagByContext(ctx *context.Context) *git_model.ProtectedTag {
return tag
}
ctx.NotFound("", fmt.Errorf("ProtectedTag[%v] not associated to repository %v", id, ctx.Repo.Repository))
ctx.NotFound(fmt.Errorf("ProtectedTag[%v] not associated to repository %v", id, ctx.Repo.Repository))
return nil
}

View File

@@ -189,13 +189,13 @@ func SettingsPost(ctx *context.Context) {
case "mirror":
if !setting.Mirror.Enabled || !repo.IsMirror || repo.IsArchived {
ctx.NotFound("", nil)
ctx.NotFound(nil)
return
}
pullMirror, err := repo_model.GetMirrorByRepoID(ctx, ctx.Repo.Repository.ID)
if err == repo_model.ErrMirrorNotExist {
ctx.NotFound("", nil)
ctx.NotFound(nil)
return
}
if err != nil {
@@ -283,7 +283,7 @@ func SettingsPost(ctx *context.Context) {
case "mirror-sync":
if !setting.Mirror.Enabled || !repo.IsMirror || repo.IsArchived {
ctx.NotFound("", nil)
ctx.NotFound(nil)
return
}
@@ -294,13 +294,13 @@ func SettingsPost(ctx *context.Context) {
case "push-mirror-sync":
if !setting.Mirror.Enabled {
ctx.NotFound("", nil)
ctx.NotFound(nil)
return
}
m, _, _ := repo_model.GetPushMirrorByIDAndRepoID(ctx, form.PushMirrorID, repo.ID)
if m == nil {
ctx.NotFound("", nil)
ctx.NotFound(nil)
return
}
@@ -311,7 +311,7 @@ func SettingsPost(ctx *context.Context) {
case "push-mirror-update":
if !setting.Mirror.Enabled || repo.IsArchived {
ctx.NotFound("", nil)
ctx.NotFound(nil)
return
}
@@ -327,7 +327,7 @@ func SettingsPost(ctx *context.Context) {
m, _, _ := repo_model.GetPushMirrorByIDAndRepoID(ctx, form.PushMirrorID, repo.ID)
if m == nil {
ctx.NotFound("", nil)
ctx.NotFound(nil)
return
}
@@ -349,7 +349,7 @@ func SettingsPost(ctx *context.Context) {
case "push-mirror-remove":
if !setting.Mirror.Enabled || repo.IsArchived {
ctx.NotFound("", nil)
ctx.NotFound(nil)
return
}
@@ -359,7 +359,7 @@ func SettingsPost(ctx *context.Context) {
m, _, _ := repo_model.GetPushMirrorByIDAndRepoID(ctx, form.PushMirrorID, repo.ID)
if m == nil {
ctx.NotFound("", nil)
ctx.NotFound(nil)
return
}
@@ -378,7 +378,7 @@ func SettingsPost(ctx *context.Context) {
case "push-mirror-add":
if setting.Mirror.DisableNewPush || repo.IsArchived {
ctx.NotFound("", nil)
ctx.NotFound(nil)
return
}
@@ -650,7 +650,7 @@ func SettingsPost(ctx *context.Context) {
case "admin":
if !ctx.Doer.IsAdmin {
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return
}
@@ -670,7 +670,7 @@ func SettingsPost(ctx *context.Context) {
case "admin_index":
if !ctx.Doer.IsAdmin {
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return
}
@@ -682,12 +682,12 @@ func SettingsPost(ctx *context.Context) {
}
case "code":
if !setting.Indexer.RepoIndexerEnabled {
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return
}
code.UpdateRepoIndexer(ctx.Repo.Repository)
default:
ctx.NotFound("", nil)
ctx.NotFound(nil)
return
}
@@ -698,7 +698,7 @@ func SettingsPost(ctx *context.Context) {
case "convert":
if !ctx.Repo.IsOwner() {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return
}
if repo.Name != form.RepoName {
@@ -707,7 +707,7 @@ func SettingsPost(ctx *context.Context) {
}
if !repo.IsMirror {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return
}
repo.IsMirror = false
@@ -725,7 +725,7 @@ func SettingsPost(ctx *context.Context) {
case "convert_fork":
if !ctx.Repo.IsOwner() {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return
}
if err := repo.LoadOwner(ctx); err != nil {
@@ -738,7 +738,7 @@ func SettingsPost(ctx *context.Context) {
}
if !repo.IsFork {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return
}
@@ -762,7 +762,7 @@ func SettingsPost(ctx *context.Context) {
case "transfer":
if !ctx.Repo.IsOwner() {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return
}
if repo.Name != form.RepoName {
@@ -820,7 +820,7 @@ func SettingsPost(ctx *context.Context) {
case "cancel_transfer":
if !ctx.Repo.IsOwner() {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return
}
@@ -846,7 +846,7 @@ func SettingsPost(ctx *context.Context) {
case "delete":
if !ctx.Repo.IsOwner() {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return
}
if repo.Name != form.RepoName {
@@ -870,7 +870,7 @@ func SettingsPost(ctx *context.Context) {
case "delete-wiki":
if !ctx.Repo.IsOwner() {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return
}
if repo.Name != form.RepoName {
@@ -889,7 +889,7 @@ func SettingsPost(ctx *context.Context) {
case "archive":
if !ctx.Repo.IsOwner() {
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return
}
@@ -920,7 +920,7 @@ func SettingsPost(ctx *context.Context) {
case "unarchive":
if !ctx.Repo.IsOwner() {
ctx.Error(http.StatusForbidden)
ctx.HTTPError(http.StatusForbidden)
return
}
@@ -979,7 +979,7 @@ func SettingsPost(ctx *context.Context) {
ctx.Redirect(ctx.Repo.RepoLink + "/settings")
default:
ctx.NotFound("", nil)
ctx.NotFound(nil)
}
}

View File

@@ -112,7 +112,7 @@ func getOwnerRepoCtx(ctx *context.Context) (*ownerRepoCtx, error) {
func checkHookType(ctx *context.Context) string {
hookType := strings.ToLower(ctx.PathParam("type"))
if !util.SliceContainsString(setting.Webhook.Types, hookType, true) {
ctx.NotFound("checkHookType", nil)
ctx.NotFound(nil)
return ""
}
return hookType
@@ -601,7 +601,7 @@ func checkWebhook(ctx *context.Context) (*ownerRepoCtx, *webhook.Webhook) {
}
if err != nil || w == nil {
if webhook.IsErrWebhookNotExist(err) {
ctx.NotFound("GetWebhookByID", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("GetWebhookByID", err)
}
@@ -718,7 +718,7 @@ func ReplayWebhook(ctx *context.Context) {
if err := webhook_service.ReplayHookTask(ctx, w, hookTaskUUID); err != nil {
if webhook.IsErrHookTaskNotExist(err) {
ctx.NotFound("ReplayHookTask", nil)
ctx.NotFound(nil)
} else {
ctx.ServerError("ReplayHookTask", err)
}

View File

@@ -216,7 +216,7 @@ func checkHomeCodeViewable(ctx *context.Context) {
}
}
ctx.NotFound("Home", errors.New(ctx.Locale.TrString("units.error.no_unit_allowed_repo")))
ctx.NotFound(errors.New(ctx.Locale.TrString("units.error.no_unit_allowed_repo")))
}
// LastCommit returns lastCommit data for the provided branch/tag/commit and directory (in url) and filenames in body

View File

@@ -58,7 +58,7 @@ func MustEnableWiki(ctx *context.Context) {
ctx.Repo.Repository,
ctx.Repo.Permission)
}
ctx.NotFound("MustEnableWiki", nil)
ctx.NotFound(nil)
return
}
@@ -485,7 +485,7 @@ func renderEditPage(ctx *context.Context) {
ctx.Redirect(ctx.Repo.RepoLink + "/wiki/?action=_pages")
}
if isRaw {
ctx.Error(http.StatusForbidden, "Editing of raw wiki files is not allowed")
ctx.HTTPError(http.StatusForbidden, "Editing of raw wiki files is not allowed")
}
if entry == nil || ctx.Written() {
return
@@ -509,14 +509,14 @@ func WikiPost(ctx *context.Context) {
switch ctx.FormString("action") {
case "_new":
if !ctx.Repo.CanWrite(unit.TypeWiki) {
ctx.NotFound(ctx.Req.URL.RequestURI(), nil)
ctx.NotFound(nil)
return
}
NewWikiPost(ctx)
return
case "_delete":
if !ctx.Repo.CanWrite(unit.TypeWiki) {
ctx.NotFound(ctx.Req.URL.RequestURI(), nil)
ctx.NotFound(nil)
return
}
DeleteWikiPagePost(ctx)
@@ -524,7 +524,7 @@ func WikiPost(ctx *context.Context) {
}
if !ctx.Repo.CanWrite(unit.TypeWiki) {
ctx.NotFound(ctx.Req.URL.RequestURI(), nil)
ctx.NotFound(nil)
return
}
EditWikiPost(ctx)
@@ -543,14 +543,14 @@ func Wiki(ctx *context.Context) {
return
case "_edit":
if !ctx.Repo.CanWrite(unit.TypeWiki) {
ctx.NotFound(ctx.Req.URL.RequestURI(), nil)
ctx.NotFound(nil)
return
}
EditWiki(ctx)
return
case "_new":
if !ctx.Repo.CanWrite(unit.TypeWiki) {
ctx.NotFound(ctx.Req.URL.RequestURI(), nil)
ctx.NotFound(nil)
return
}
NewWiki(ctx)
@@ -710,7 +710,7 @@ func WikiRaw(ctx *context.Context) {
if err != nil {
if git.IsErrNotExist(err) {
ctx.NotFound("findEntryForFile", nil)
ctx.NotFound(nil)
return
}
ctx.ServerError("findEntryForfile", err)
@@ -746,7 +746,7 @@ func WikiRaw(ctx *context.Context) {
return
}
ctx.NotFound("findEntryForFile", nil)
ctx.NotFound(nil)
}
// NewWiki render wiki create page