diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 4cc007e9e..78fe4b25d 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -36,7 +36,7 @@ func Issues(ctx *middleware.Context, params martini.Params) { func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.CreateIssueForm) { if !ctx.Repo.IsOwner { - ctx.Error(404) + ctx.Handle(404, "issue.CreateIssue", nil) return } @@ -65,14 +65,14 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat func ViewIssue(ctx *middleware.Context, params martini.Params) { issueid, err := base.StrTo(params["issueid"]).Int() if err != nil { - ctx.Error(404) + ctx.Handle(404, "issue.ViewIssue", err) return } issue, err := models.GetIssueById(int64(issueid)) if err != nil { if err == models.ErrIssueNotExist { - ctx.Error(404) + ctx.Handle(404, "issue.ViewIssue", err) } else { ctx.Handle(200, "issue.ViewIssue", err) } diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 4782d64f7..0f1ea3123 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -86,7 +86,7 @@ func Branches(ctx *middleware.Context, params martini.Params) { ctx.Handle(200, "repo.Branches", err) return } else if len(brs) == 0 { - ctx.Error(404) + ctx.Handle(404, "repo.Branches", nil) return } @@ -123,8 +123,8 @@ func Single(ctx *middleware.Context, params martini.Params) { // Branches. brs, err := models.GetBranches(params["username"], params["reponame"]) if err != nil { - log.Error("repo.Single(GetBranches): %v", err) - ctx.Error(404) + //log.Error("repo.Single(GetBranches): %v", err) + ctx.Handle(404, "repo.Single(GetBranches)", err) return } else if ctx.Repo.Repository.IsBare { ctx.Data["IsBareRepo"] = true @@ -138,15 +138,15 @@ func Single(ctx *middleware.Context, params martini.Params) { params["branchname"], params["commitid"], treename) if err != nil && err != models.ErrRepoFileNotExist { - log.Error("repo.Single(GetTargetFile): %v", err) - ctx.Error(404) + //log.Error("repo.Single(GetTargetFile): %v", err) + ctx.Handle(404, "repo.Single(GetTargetFile)", err) return } branchLink := "/" + ctx.Repo.Owner.LowerName + "/" + ctx.Repo.Repository.Name + "/src/" + params["branchname"] if len(treename) != 0 && repoFile == nil { - ctx.Error(404) + ctx.Handle(404, "repo.Single", nil) return } @@ -154,8 +154,8 @@ func Single(ctx *middleware.Context, params martini.Params) { if repoFile.Size > 1024*1024 || repoFile.Filemode != git.FileModeBlob { ctx.Data["FileIsLarge"] = true } else if blob, err := repoFile.LookupBlob(); err != nil { - log.Error("repo.Single(repoFile.LookupBlob): %v", err) - ctx.Error(404) + //log.Error("repo.Single(repoFile.LookupBlob): %v", err) + ctx.Handle(404, "repo.Single(repoFile.LookupBlob)", err) } else { ctx.Data["IsFile"] = true ctx.Data["FileName"] = repoFile.Name @@ -179,8 +179,8 @@ func Single(ctx *middleware.Context, params martini.Params) { files, err := models.GetReposFiles(params["username"], params["reponame"], params["branchname"], params["commitid"], treename) if err != nil { - log.Error("repo.Single(GetReposFiles): %v", err) - ctx.Error(404) + //log.Error("repo.Single(GetReposFiles): %v", err) + ctx.Handle(404, "repo.Single(GetReposFiles)", err) return } @@ -203,8 +203,8 @@ func Single(ctx *middleware.Context, params martini.Params) { if readmeFile.Size > 1024*1024 || readmeFile.Filemode != git.FileModeBlob { ctx.Data["FileIsLarge"] = true } else if blob, err := readmeFile.LookupBlob(); err != nil { - log.Error("repo.Single(readmeFile.LookupBlob): %v", err) - ctx.Error(404) + //log.Error("repo.Single(readmeFile.LookupBlob): %v", err) + ctx.Handle(404, "repo.Single(readmeFile.LookupBlob)", err) return } else { // current repo branch link @@ -239,7 +239,7 @@ func Single(ctx *middleware.Context, params martini.Params) { params["branchname"], params["commitid"]) if err != nil { log.Error("repo.Single(GetCommit): %v", err) - ctx.Error(404) + ctx.Handle(404, "repo.Single(GetCommit)", err) return } ctx.Data["LastCommit"] = commit @@ -275,7 +275,7 @@ func Http(ctx *middleware.Context, params martini.Params) { func Setting(ctx *middleware.Context, params martini.Params) { if !ctx.Repo.IsOwner { - ctx.Error(404) + ctx.Handle(404, "repo.Setting", nil) return } @@ -307,7 +307,7 @@ func Commits(ctx *middleware.Context, params martini.Params) { ctx.Handle(200, "repo.Commits", err) return } else if len(brs) == 0 { - ctx.Error(404) + ctx.Handle(404, "repo.Commits", nil) return } @@ -315,7 +315,7 @@ func Commits(ctx *middleware.Context, params martini.Params) { commits, err := models.GetCommits(params["username"], params["reponame"], params["branchname"]) if err != nil { - ctx.Error(404) + ctx.Handle(404, "repo.Commits", nil) return } ctx.Data["Username"] = params["username"] diff --git a/routers/user/user.go b/routers/user/user.go index c34b529ec..a0321f187 100644 --- a/routers/user/user.go +++ b/routers/user/user.go @@ -301,7 +301,7 @@ func Activate(ctx *middleware.Context) { if len(code) == 0 { ctx.Data["IsActivatePage"] = true if ctx.User.IsActive { - ctx.Error(404) + ctx.Handle(404, "user.Activate", nil) return } // Resend confirmation e-mail. diff --git a/templates/status/404.tmpl b/templates/status/404.tmpl new file mode 100644 index 000000000..4e836b228 --- /dev/null +++ b/templates/status/404.tmpl @@ -0,0 +1,7 @@ +{{template "base/head" .}} +{{template "base/navbar" .}} +
Application Version: {{AppVer}}
+An error is occurred : {{.ErrorMsg}}
+Application Version: {{AppVer}}
+