mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-19 15:14:40 +09:00
refactor: clean up error system (#40328)
1. `ctx.ServerError("LogMessage", err)` is very messy and useless. When
the log is printed, it already contains the caller's file and line
number
2. `ctx.NotFound(nil)` and `ctx.NotFound(err)` were abused a lot, now
only `ctx.NotFound()`
---------
Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
1 parent
a61ef7aa14
commit
b3422c0920
167 files changed
+1530
-1773
No files matched your search
+1
-4
@@ -22,9 +22,6 @@ var hookNames = []string{
|
||||
"post-receive",
|
||||
}
|
||||
|
||||
// ErrNotValidHook error when a git hook is not valid
|
||||
var ErrNotValidHook = errors.New("not a valid Git hook")
|
||||
|
||||
// IsValidHookName returns true if given name is a valid Git hook.
|
||||
func IsValidHookName(name string) bool {
|
||||
return slices.Contains(hookNames, name)
|
||||
@@ -43,7 +40,7 @@ type Hook struct {
|
||||
func GetHook(repo RepositoryFacade, name string) (*Hook, error) {
|
||||
repoPath := gitrepo.RepoLocalPath(repo)
|
||||
if !IsValidHookName(name) {
|
||||
return nil, ErrNotValidHook
|
||||
return nil, util.NewNotExistErrorf("invalid hook name: %s", name)
|
||||
}
|
||||
h := &Hook{
|
||||
name: name,
|
||||
|
||||
@@ -267,3 +267,12 @@ func IsClientOrNetworkError(ctx context.Context, err error) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func ClientAcceptHTML(req *http.Request) bool {
|
||||
for _, part := range req.Header["Accept"] {
|
||||
if strings.Contains(part, "text/html") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -89,7 +89,7 @@ func enumeratePackages(ctx *context.Context, filename string, pvs []*packages_mo
|
||||
zw.Name = filename
|
||||
|
||||
if err := rubygems_module.NewMarshalEncoder(zw).Encode(specs); err != nil {
|
||||
ctx.ServerError("Download file failed", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ func ServePackageSpecification(ctx *context.Context) {
|
||||
}
|
||||
|
||||
if err := rubygems_module.NewMarshalEncoder(zw).Encode(spec); err != nil {
|
||||
ctx.ServerError("Download file failed", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -311,11 +311,6 @@ func ListBranches(ctx *context.APIContext) {
|
||||
keyword := ctx.FormString("q")
|
||||
|
||||
if !ctx.Repo.Repository.IsEmpty {
|
||||
if ctx.Repo.GitRepo == nil {
|
||||
ctx.APIErrorInternal(nil)
|
||||
return
|
||||
}
|
||||
|
||||
branchOpts := git_model.FindBranchOptions{
|
||||
ListOptions: listOptions,
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
package repo
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"gitea.dev/modules/git"
|
||||
@@ -83,11 +82,7 @@ func GetGitHook(ctx *context.APIContext) {
|
||||
hookID := ctx.PathParam("id")
|
||||
hook, err := git.GetHook(ctx.Repo.GitRepo, hookID)
|
||||
if err != nil {
|
||||
if errors.Is(err, git.ErrNotValidHook) {
|
||||
ctx.APIErrorNotFound()
|
||||
} else {
|
||||
ctx.APIErrorInternal(err)
|
||||
}
|
||||
ctx.APIErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK, convert.ToGitHook(hook))
|
||||
@@ -130,11 +125,7 @@ func EditGitHook(ctx *context.APIContext) {
|
||||
hookID := ctx.PathParam("id")
|
||||
hook, err := git.GetHook(ctx.Repo.GitRepo, hookID)
|
||||
if err != nil {
|
||||
if errors.Is(err, git.ErrNotValidHook) {
|
||||
ctx.APIErrorNotFound()
|
||||
} else {
|
||||
ctx.APIErrorInternal(err)
|
||||
}
|
||||
ctx.APIErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -179,11 +170,7 @@ func DeleteGitHook(ctx *context.APIContext) {
|
||||
hookID := ctx.PathParam("id")
|
||||
hook, err := git.GetHook(ctx.Repo.GitRepo, hookID)
|
||||
if err != nil {
|
||||
if errors.Is(err, git.ErrNotValidHook) {
|
||||
ctx.APIErrorNotFound()
|
||||
} else {
|
||||
ctx.APIErrorInternal(err)
|
||||
}
|
||||
ctx.APIErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
user_model "gitea.dev/models/user"
|
||||
"gitea.dev/modules/httpcache"
|
||||
"gitea.dev/modules/httplib"
|
||||
"gitea.dev/modules/log"
|
||||
"gitea.dev/modules/reqctx"
|
||||
"gitea.dev/modules/setting"
|
||||
@@ -28,20 +28,12 @@ const (
|
||||
)
|
||||
|
||||
func renderServerErrorPage(w http.ResponseWriter, req *http.Request, respCode int, tmpl templates.TplName, ctxData map[string]any, plainMsg string) {
|
||||
acceptsHTML := false
|
||||
for _, part := range req.Header["Accept"] {
|
||||
if strings.Contains(part, "text/html") {
|
||||
acceptsHTML = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
httpcache.SetCacheControlInHeader(w.Header(), &httpcache.CacheControlOptions{})
|
||||
tmplCtx := context.NewTemplateContextForWeb(reqctx.FromContext(req.Context()), req, middleware.Locale(w, req))
|
||||
w.WriteHeader(respCode)
|
||||
|
||||
outBuf := &bytes.Buffer{}
|
||||
if acceptsHTML {
|
||||
if httplib.ClientAcceptHTML(req) {
|
||||
err := templates.PageRenderer().HTML(outBuf, respCode, tmpl, ctxData, tmplCtx)
|
||||
if err != nil {
|
||||
log.Error("Failed to render error page template %s: %v", tmpl, err)
|
||||
|
||||
@@ -480,7 +480,7 @@ func initAdminUser(ctx *context.Context, form *forms.InstallForm) bool {
|
||||
|
||||
nt, token, err := auth_service.CreateAuthTokenForUserID(ctx, adminUser.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("CreateAuthTokenForUserID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -258,13 +258,13 @@ func MonitorStats(ctx *context.Context) {
|
||||
ctx.Data["PageIsAdminMonitorStats"] = true
|
||||
bs, err := json.Marshal(activities_model.GetStatistic(ctx).Counter)
|
||||
if err != nil {
|
||||
ctx.ServerError("MonitorStats", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
statsCounter := map[string]any{}
|
||||
err = json.Unmarshal(bs, &statsCounter)
|
||||
if err != nil {
|
||||
ctx.ServerError("MonitorStats", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
statsKeys := make([]string, 0, len(statsCounter))
|
||||
|
||||
@@ -37,7 +37,7 @@ func Applications(ctx *context.Context) {
|
||||
IsGlobal: true,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetOAuth2ApplicationsByUserID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Applications"] = apps
|
||||
|
||||
@@ -40,7 +40,7 @@ func ExportAuditLogs(ctx *context.Context) {
|
||||
// the first page is fetched before any header is written so a failing query still results in a proper error page
|
||||
events, total, err := findPage()
|
||||
if err != nil {
|
||||
ctx.ServerError("FindEvents", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ func Authentications(ctx *context.Context) {
|
||||
var err error
|
||||
ctx.Data["Sources"], ctx.Data["Total"], err = db.FindAndCount[auth.Source](ctx, auth.FindSourcesOptions{})
|
||||
if err != nil {
|
||||
ctx.ServerError("auth.Sources", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ func NewAuthSourcePost(ctx *context.Context) {
|
||||
ctx.Data["Err_DiscoveryURL"] = true
|
||||
ctx.RenderWithErrDeprecated(ctx.Tr("admin.auths.unable_to_initialize_openid", errInit.Unwrap()), tplAuthNew, form)
|
||||
} else {
|
||||
ctx.ServerError("auth.CreateSource", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -336,7 +336,7 @@ func EditAuthSource(ctx *context.Context) {
|
||||
|
||||
source, err := auth.GetSourceByID(ctx, ctx.PathParamInt64("authid"))
|
||||
if err != nil {
|
||||
ctx.ServerError("auth.GetSourceByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Source"] = source
|
||||
@@ -367,7 +367,7 @@ func EditAuthSourcePost(ctx *context.Context) {
|
||||
|
||||
source, err := auth.GetSourceByID(ctx, ctx.PathParamInt64("authid"))
|
||||
if err != nil {
|
||||
ctx.ServerError("auth.GetSourceByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Source"] = source
|
||||
@@ -425,7 +425,7 @@ func EditAuthSourcePost(ctx *context.Context) {
|
||||
ctx.Data["Err_DiscoveryURL"] = true
|
||||
ctx.HTML(http.StatusOK, tplAuthEdit)
|
||||
} else {
|
||||
ctx.ServerError("UpdateSource", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -439,7 +439,7 @@ func EditAuthSourcePost(ctx *context.Context) {
|
||||
func DeleteAuthSource(ctx *context.Context) {
|
||||
source, err := auth.GetSourceByID(ctx, ctx.PathParamInt64("authid"))
|
||||
if err != nil {
|
||||
ctx.ServerError("auth.GetSourceByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -71,7 +71,7 @@ func NewBadgePost(ctx *context.Context) {
|
||||
if errors.Is(err, util.ErrAlreadyExist) {
|
||||
ctx.JSONError(ctx.Tr("admin.badges.slug_been_taken"))
|
||||
} else {
|
||||
ctx.ServerError("CreateBadge", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -88,7 +88,7 @@ func prepareBadgeInfo(ctx *context.Context) *user_model.Badge {
|
||||
if errors.Is(err, util.ErrNotExist) {
|
||||
ctx.Redirect(setting.AppSubURL + "/-/admin/badges")
|
||||
} else {
|
||||
ctx.ServerError("GetBadge", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -114,7 +114,7 @@ func ViewBadge(ctx *context.Context) {
|
||||
}
|
||||
users, count, err := user_model.GetBadgeUsers(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetBadgeUsers", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Users"] = users
|
||||
@@ -152,7 +152,7 @@ func EditBadgePost(ctx *context.Context) {
|
||||
b.Description = form.Description
|
||||
|
||||
if err := user_model.UpdateBadge(ctx, b); err != nil {
|
||||
ctx.ServerError("UpdateBadge", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -166,12 +166,12 @@ func EditBadgePost(ctx *context.Context) {
|
||||
func DeleteBadge(ctx *context.Context) {
|
||||
b, err := user_model.GetBadge(ctx, ctx.PathParam("badge_slug"))
|
||||
if err != nil {
|
||||
ctx.ServerError("GetBadge", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err = user_model.DeleteBadge(ctx, b); err != nil {
|
||||
ctx.ServerError("DeleteBadge", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ func BadgeUsers(ctx *context.Context) {
|
||||
}
|
||||
users, count, err := user_model.GetBadgeUsers(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetBadgeUsers", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ func BadgeUsersPost(ctx *context.Context) {
|
||||
ctx.Flash.Error(ctx.Tr("form.user_not_exist"))
|
||||
ctx.Redirect(setting.AppSubURL + ctx.Req.URL.EscapedPath())
|
||||
} else {
|
||||
ctx.ServerError("GetUserByName", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -231,7 +231,7 @@ func BadgeUsersPost(ctx *context.Context) {
|
||||
ctx.Flash.Error(ctx.Tr("admin.badges.user_already_has"))
|
||||
ctx.Redirect(setting.AppSubURL + ctx.Req.URL.EscapedPath())
|
||||
} else {
|
||||
ctx.ServerError("AddUserBadge", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -251,14 +251,14 @@ func DeleteBadgeUser(ctx *context.Context) {
|
||||
ctx.JSONRedirect(badgeUsersURL)
|
||||
return
|
||||
} else {
|
||||
ctx.ServerError("GetUserByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
if err := user_model.RemoveUserBadge(ctx, user, &user_model.Badge{Slug: ctx.PathParam("badge_slug")}); err == nil {
|
||||
ctx.Flash.Success(ctx.Tr("admin.badges.user_remove_success"))
|
||||
} else {
|
||||
ctx.ServerError("RemoveUserBadge", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ func RenderBadgeSearch(ctx *context.Context, opts *user_model.SearchBadgeOptions
|
||||
if len(opts.Keyword) == 0 || isKeywordValid(opts.Keyword) {
|
||||
badges, count, err = user_model.SearchBadges(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchBadges", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ loop:
|
||||
return
|
||||
}
|
||||
if err := system_model.SetSettings(ctx, configSettings); err != nil {
|
||||
ctx.ServerError("SetSettings", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
config.GetDynGetter().InvalidateCache()
|
||||
|
||||
@@ -29,14 +29,14 @@ func MonitorDiagnosis(ctx *context.Context) {
|
||||
|
||||
f, err := zipWriter.CreateHeader(&zip.FileHeader{Name: "goroutine-before.txt", Method: zip.Deflate, Modified: time.Now()})
|
||||
if err != nil {
|
||||
ctx.ServerError("Failed to create zip file", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
_ = pprof.Lookup("goroutine").WriteTo(f, 1)
|
||||
|
||||
f, err = zipWriter.CreateHeader(&zip.FileHeader{Name: "cpu-profile.dat", Method: zip.Deflate, Modified: time.Now()})
|
||||
if err != nil {
|
||||
ctx.ServerError("Failed to create zip file", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -50,21 +50,21 @@ func MonitorDiagnosis(ctx *context.Context) {
|
||||
|
||||
f, err = zipWriter.CreateHeader(&zip.FileHeader{Name: "goroutine-after.txt", Method: zip.Deflate, Modified: time.Now()})
|
||||
if err != nil {
|
||||
ctx.ServerError("Failed to create zip file", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
_ = pprof.Lookup("goroutine").WriteTo(f, 1)
|
||||
|
||||
f, err = zipWriter.CreateHeader(&zip.FileHeader{Name: "heap.dat", Method: zip.Deflate, Modified: time.Now()})
|
||||
if err != nil {
|
||||
ctx.ServerError("Failed to create zip file", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
_ = pprof.Lookup("heap").WriteTo(f, 0)
|
||||
|
||||
f, err = zipWriter.CreateHeader(&zip.FileHeader{Name: "perftrace.txt", Method: zip.Deflate, Modified: time.Now()})
|
||||
if err != nil {
|
||||
ctx.ServerError("Failed to create zip file", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
for _, record := range tailmsg.GetManager().GetTraceRecorder().GetRecords() {
|
||||
|
||||
@@ -80,7 +80,7 @@ func Emails(ctx *context.Context) {
|
||||
if len(opts.Keyword) == 0 || isKeywordValid(opts.Keyword) {
|
||||
baseEmails, count, err = user_model.SearchEmails(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchEmails", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
emails = make([]ActiveEmail, len(baseEmails))
|
||||
@@ -164,13 +164,13 @@ func ActivateEmail(ctx *context.Context) {
|
||||
func DeleteEmail(ctx *context.Context) {
|
||||
u, err := user_model.GetUserByID(ctx, ctx.FormInt64("uid"))
|
||||
if err != nil || u == nil {
|
||||
ctx.ServerError("GetUserByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
email, err := user_model.GetEmailAddressByID(ctx, u.ID, ctx.FormInt64("id"))
|
||||
if err != nil || email == nil {
|
||||
ctx.ServerError("GetEmailAddressByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ func DeleteEmail(ctx *context.Context) {
|
||||
ctx.JSONRedirect("")
|
||||
return
|
||||
}
|
||||
ctx.ServerError("DeleteEmailAddresses", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
log.Trace("Email address deleted: %s %s", u.Name, email.Email)
|
||||
|
||||
@@ -40,7 +40,7 @@ func DefaultOrSystemWebhooks(ctx *context.Context) {
|
||||
sys["BaseLink"] = setting.AppSubURL + "/-/admin/hooks"
|
||||
sys["BaseLinkNew"] = setting.AppSubURL + "/-/admin/system-hooks"
|
||||
if err != nil {
|
||||
ctx.ServerError("GetWebhooksAdmin", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func DefaultOrSystemWebhooks(ctx *context.Context) {
|
||||
def["BaseLink"] = setting.AppSubURL + "/-/admin/hooks"
|
||||
def["BaseLinkNew"] = setting.AppSubURL + "/-/admin/default-hooks"
|
||||
if err != nil {
|
||||
ctx.ServerError("GetWebhooksAdmin", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ func Notices(ctx *context.Context) {
|
||||
|
||||
notices, err := system_model.Notices(ctx, page, setting.UI.Admin.NoticePagingNum)
|
||||
if err != nil {
|
||||
ctx.ServerError("Notices", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Notices"] = notices
|
||||
@@ -65,7 +65,7 @@ func DeleteNotices(ctx *context.Context) {
|
||||
// EmptyNotices delete all the notices
|
||||
func EmptyNotices(ctx *context.Context) {
|
||||
if err := system_model.DeleteNotices(ctx, 0, 0); err != nil {
|
||||
ctx.ServerError("DeleteNotices", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -39,25 +39,25 @@ func Packages(ctx *context.Context) {
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchVersions", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
pds, err := packages_model.GetPackageDescriptors(ctx, pvs)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetPackageDescriptors", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
totalBlobSize, err := packages_model.GetTotalBlobSize(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetTotalBlobSize", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
totalUnreferencedBlobSize, err := packages_model.GetTotalUnreferencedBlobSize(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("CalculateBlobSize", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -82,12 +82,12 @@ func Packages(ctx *context.Context) {
|
||||
func DeletePackageVersion(ctx *context.Context) {
|
||||
pv, err := packages_model.GetVersionByID(ctx, ctx.FormInt64("id"))
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRepositoryByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := packages_service.RemovePackageVersion(ctx, ctx.Doer, pv); err != nil {
|
||||
ctx.ServerError("RemovePackageVersion", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ func DeletePackageVersion(ctx *context.Context) {
|
||||
|
||||
func CleanupExpiredData(ctx *context.Context) {
|
||||
if err := packages_cleanup_service.CleanupExpiredData(ctx, time.Duration(0)); err != nil {
|
||||
ctx.ServerError("CleanupExpiredData", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ func QueueRemoveAllItems(ctx *context.Context) {
|
||||
}
|
||||
|
||||
if err := mq.RemoveAllItems(ctx); err != nil {
|
||||
ctx.ServerError("RemoveAllItems", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -34,12 +34,12 @@ func Repos(ctx *context.Context) {
|
||||
func DeleteRepo(ctx *context.Context) {
|
||||
repo, err := repo_model.GetRepositoryByID(ctx, ctx.FormInt64("id"))
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRepositoryByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := repo_service.DeleteRepository(ctx, ctx.Doer, repo, true); err != nil {
|
||||
ctx.ServerError("DeleteRepository", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
log.Trace("Repository deleted: %s", repo.FullName())
|
||||
|
||||
@@ -34,7 +34,7 @@ func Stacktrace(ctx *context.Context) {
|
||||
showNoSystem := show == "process"
|
||||
processStacks, processCount, _, err := process.GetManager().ProcessStacktraces(false, showNoSystem)
|
||||
if err != nil {
|
||||
ctx.ServerError("GoroutineStacktrace", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+24
-24
@@ -85,7 +85,7 @@ func Users(ctx *context.Context) {
|
||||
// inactive sources are listed too, users stay attached to a source after it is deactivated
|
||||
sources, err := db.Find[auth.Source](ctx, auth.FindSourcesOptions{})
|
||||
if err != nil {
|
||||
ctx.ServerError("auth.Sources", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
sourceIDFilter := ctx.FormOptionalInt64("source_id")
|
||||
@@ -137,7 +137,7 @@ func NewUser(ctx *context.Context) {
|
||||
IsActive: optional.Some(true),
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("auth.Sources", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Sources"] = sources
|
||||
@@ -158,7 +158,7 @@ func NewUserPost(ctx *context.Context) {
|
||||
IsActive: optional.Some(true),
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("auth.Sources", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Sources"] = sources
|
||||
@@ -243,7 +243,7 @@ func NewUserPost(ctx *context.Context) {
|
||||
ctx.Data["Err_UserName"] = true
|
||||
ctx.RenderWithErrDeprecated(ctx.Tr("user.form.name_chars_not_allowed", errNameCharsNotAllowed.Name), tplUserNew, &form)
|
||||
default:
|
||||
ctx.ServerError("CreateUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -271,7 +271,7 @@ func prepareUserInfo(ctx *context.Context) *user_model.User {
|
||||
if user_model.IsErrUserNotExist(err) {
|
||||
ctx.Redirect(setting.AppSubURL + "/-/admin/users")
|
||||
} else {
|
||||
ctx.ServerError("GetUserByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -280,7 +280,7 @@ func prepareUserInfo(ctx *context.Context) *user_model.User {
|
||||
if u.LoginSource > 0 {
|
||||
ctx.Data["LoginSource"], err = auth.GetSourceByID(ctx, u.LoginSource)
|
||||
if err != nil {
|
||||
ctx.ServerError("auth.GetSourceByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
@@ -289,19 +289,19 @@ func prepareUserInfo(ctx *context.Context) *user_model.User {
|
||||
|
||||
sources, err := db.Find[auth.Source](ctx, auth.FindSourcesOptions{})
|
||||
if err != nil {
|
||||
ctx.ServerError("auth.Sources", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
ctx.Data["Sources"] = sources
|
||||
|
||||
hasTOTP, err := auth.HasTwoFactorByUID(ctx, u.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("auth.HasTwoFactorByUID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
hasWebAuthn, err := auth.HasWebAuthnRegistrationsByUID(ctx, u.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("auth.HasWebAuthnRegistrationsByUID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
ctx.Data["TwoFactorEnabled"] = hasTOTP || hasWebAuthn
|
||||
@@ -330,7 +330,7 @@ func ViewUser(ctx *context.Context) {
|
||||
Collaborate: optional.Some(false),
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchRepository", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ func ViewUser(ctx *context.Context) {
|
||||
|
||||
emails, err := user_model.GetEmailAddresses(ctx, u.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetEmailAddresses", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Emails"] = emails
|
||||
@@ -347,7 +347,7 @@ func ViewUser(ctx *context.Context) {
|
||||
|
||||
ctx.Data["UserOrgs"], err = org_model.GetUserOrganizations(ctx, u.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("FindOrgs", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -365,7 +365,7 @@ func ViewUser(ctx *context.Context) {
|
||||
func getTargetBot(ctx *context.Context) *user_model.User {
|
||||
u, err := user_model.GetUserByID(ctx, ctx.PathParamInt64("userid"))
|
||||
if err != nil {
|
||||
ctx.ServerError("GetUserByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
if !u.IsTypeBot() {
|
||||
@@ -450,7 +450,7 @@ func EditUserPost(ctx *context.Context) {
|
||||
ctx.Data["Err_UserName"] = true
|
||||
ctx.RenderWithErrDeprecated(ctx.Tr("user.form.name_chars_not_allowed", form.UserName), tplUserEdit, &form)
|
||||
default:
|
||||
ctx.ServerError("RenameUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -496,7 +496,7 @@ func EditUserPost(ctx *context.Context) {
|
||||
ctx.Flash.Error(err.Error())
|
||||
ctx.Redirect(userLink)
|
||||
default:
|
||||
ctx.ServerError("UpdateUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -511,7 +511,7 @@ func EditUserPost(ctx *context.Context) {
|
||||
ctx.Data["Err_Email"] = true
|
||||
ctx.RenderWithErrDeprecated(ctx.Tr("form.email_invalid"), tplUserEdit, &form)
|
||||
default:
|
||||
ctx.ServerError("AddOrSetPrimaryEmailAddress", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -547,7 +547,7 @@ func EditUserPost(ctx *context.Context) {
|
||||
ctx.Flash.Error(err.Error())
|
||||
ctx.Redirect(userLink)
|
||||
default:
|
||||
ctx.ServerError("UpdateUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -556,7 +556,7 @@ func EditUserPost(ctx *context.Context) {
|
||||
|
||||
if form.Reset2FA {
|
||||
if _, _, err := auth.DisableTwoFactor(ctx, u.ID); err != nil {
|
||||
ctx.ServerError("auth.DisableTwoFactor", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -579,7 +579,7 @@ func ImpersonateUser(ctx *context.Context) {
|
||||
|
||||
err = auth_service.ImpersonateUser(ctx.Session, u)
|
||||
if err != nil {
|
||||
ctx.ServerError("unable to impersonate user", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
audit.Record(ctx, audit_model.UserImpersonation, u)
|
||||
@@ -590,7 +590,7 @@ func ImpersonateUser(ctx *context.Context) {
|
||||
func DeleteUser(ctx *context.Context) {
|
||||
u, err := user_model.GetUserByID(ctx, ctx.PathParamInt64("userid"))
|
||||
if err != nil {
|
||||
ctx.ServerError("GetUserByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -616,7 +616,7 @@ func DeleteUser(ctx *context.Context) {
|
||||
ctx.Flash.Error(ctx.Tr("auth.last_admin"))
|
||||
ctx.Redirect(setting.AppSubURL + "/-/admin/users/" + url.PathEscape(ctx.PathParam("userid")))
|
||||
default:
|
||||
ctx.ServerError("DeleteUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -635,7 +635,7 @@ func RemoveUserFromOrg(ctx *context.Context) {
|
||||
orgID := ctx.PathParamInt64("org_id")
|
||||
org, err := org_model.GetOrgByID(ctx, orgID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetOrgByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -645,7 +645,7 @@ func RemoveUserFromOrg(ctx *context.Context) {
|
||||
ctx.JSONRedirect("")
|
||||
return
|
||||
} else if err != nil {
|
||||
ctx.ServerError("RemoveOrgUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -661,7 +661,7 @@ func RemoveUserFromAllOrgs(ctx *context.Context) {
|
||||
|
||||
orgs, err := org_model.GetUserOrganizations(ctx, u.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetUserOrganizations", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+13
-13
@@ -36,7 +36,7 @@ func TwoFactor(ctx *context.Context) {
|
||||
|
||||
// Ensure user is in a 2FA session.
|
||||
if ctx.Session.Get("twofaUid") == nil {
|
||||
ctx.ServerError("UserSignIn", errors.New("not in 2FA session"))
|
||||
ctx.ServerErrorAuto(errors.New("not in 2FA session"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -51,20 +51,20 @@ func TwoFactorPost(ctx *context.Context) {
|
||||
// Ensure user is in a 2FA session.
|
||||
id, hasSession := ctx.Session.Get("twofaUid").(int64)
|
||||
if !hasSession {
|
||||
ctx.ServerError("UserSignIn", errors.New("not in 2FA session"))
|
||||
ctx.ServerErrorAuto(errors.New("not in 2FA session"))
|
||||
return
|
||||
}
|
||||
|
||||
twofa, err := auth.GetTwoFactorByUID(ctx, id)
|
||||
if err != nil {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
// Validate the passcode and atomically consume it to prevent reuse/replay.
|
||||
tfaResult, err := twofa.ValidateAndConsumeTOTP(ctx, form.Passcode)
|
||||
if err != nil {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -72,12 +72,12 @@ func TwoFactorPost(ctx *context.Context) {
|
||||
remember := ctx.Session.Get("twofaRemember").(bool) //nolint:forcetypeassert // must exist
|
||||
u, err := user_model.GetUserByID(ctx, id)
|
||||
if err != nil {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err = completePendingLinks(ctx, u); err != nil {
|
||||
ctx.ServerError("completePendingLinks", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ func TwoFactorScratch(ctx *context.Context) {
|
||||
|
||||
// Ensure user is in a 2FA session.
|
||||
if ctx.Session.Get("twofaUid") == nil {
|
||||
ctx.ServerError("UserSignIn", errors.New("not in 2FA session"))
|
||||
ctx.ServerErrorAuto(errors.New("not in 2FA session"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -119,13 +119,13 @@ func TwoFactorScratchPost(ctx *context.Context) {
|
||||
// Ensure user is in a 2FA session.
|
||||
id, hasSession := ctx.Session.Get("twofaUid").(int64)
|
||||
if !hasSession {
|
||||
ctx.ServerError("UserSignIn", errors.New("not in 2FA session"))
|
||||
ctx.ServerErrorAuto(errors.New("not in 2FA session"))
|
||||
return
|
||||
}
|
||||
|
||||
twofa, err := auth.GetTwoFactorByUID(ctx, id)
|
||||
if err != nil {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -134,23 +134,23 @@ func TwoFactorScratchPost(ctx *context.Context) {
|
||||
// Invalidate the scratch token.
|
||||
_, err = twofa.GenerateScratchToken()
|
||||
if err != nil {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if err = auth.UpdateTwoFactor(ctx, twofa); err != nil {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
remember := ctx.Session.Get("twofaRemember").(bool) //nolint:forcetypeassert // must exist
|
||||
u, err := user_model.GetUserByID(ctx, id)
|
||||
if err != nil {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err = completePendingLinks(ctx, u); err != nil {
|
||||
ctx.ServerError("completePendingLinks", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+26
-34
@@ -211,7 +211,7 @@ func performAutoLogin(ctx *context.Context) bool {
|
||||
ctx.Flash.Error(ctx.Tr("auth.remember_me.compromised"), true)
|
||||
return false
|
||||
}
|
||||
ctx.ServerError("autoSignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ func SignInPost(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("auth.prohibit_login")
|
||||
ctx.HTML(http.StatusOK, "user/auth/prohibit_login")
|
||||
} else {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -334,7 +334,7 @@ func SignInPost(ctx *context.Context) {
|
||||
// Instead, redirect them to the 2FA authentication page.
|
||||
hasTwoFactor, err := auth.HasTwoFactorOrWebAuthn(ctx, u.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("HasTwoFactorOrWebAuthn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if !hasTwoFactor {
|
||||
@@ -349,12 +349,12 @@ func handleTwoFactorRequired(ctx *context.Context, u *user_model.User, remember
|
||||
updates := map[string]any{"twofaUid": u.ID, "twofaRemember": remember}
|
||||
maps.Copy(updates, extra)
|
||||
if err := regenerateSession(ctx, updates); err != nil {
|
||||
ctx.ServerError("RegenerateSession", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
hasWebAuthn, err := auth.HasWebAuthnRegistrationsByUID(ctx, u.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("HasWebAuthnRegistrationsByUID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if hasWebAuthn {
|
||||
@@ -380,7 +380,7 @@ func handleSignInFull(ctx *context.Context, u *user_model.User, remember bool) {
|
||||
}
|
||||
nt, token, err := auth_service.CreateAuthTokenForUserID(ctx, u.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("CreateAuthTokenForUserID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -389,7 +389,7 @@ func handleSignInFull(ctx *context.Context, u *user_model.User, remember bool) {
|
||||
|
||||
userHasTwoFactorAuth, err := auth.HasTwoFactorOrWebAuthn(ctx, u.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("HasTwoFactorOrWebAuthn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ func handleSignInFull(ctx *context.Context, u *user_model.User, remember bool) {
|
||||
session.KeyUID: u.ID,
|
||||
session.KeyUserHasTwoFactorAuth: userHasTwoFactorAuth,
|
||||
}); err != nil {
|
||||
ctx.ServerError("RegenerateSession", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -409,7 +409,7 @@ func handleSignInFull(ctx *context.Context, u *user_model.User, remember bool) {
|
||||
Language: optional.Some(ctx.Locale.Language()),
|
||||
}
|
||||
if err := user_service.UpdateUser(ctx, u, opts); err != nil {
|
||||
ctx.ServerError("UpdateUser Language", fmt.Errorf("Error updating user language [user: %d, locale: %s]", u.ID, ctx.Locale.Language()))
|
||||
ctx.ServerErrorAuto(fmt.Errorf("Error updating user language [user: %d, locale: %s]", u.ID, ctx.Locale.Language()))
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -422,7 +422,7 @@ func handleSignInFull(ctx *context.Context, u *user_model.User, remember bool) {
|
||||
|
||||
// Register last login
|
||||
if err := user_service.UpdateUser(ctx, u, &user_service.UpdateOptions{SetLastLogin: true}); err != nil {
|
||||
ctx.ServerError("UpdateUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -473,7 +473,7 @@ func SignOut(ctx *context.Context) {
|
||||
|
||||
exitedImpersonated, err := auth_service.ExitImpersonatedUser(ctx.Session)
|
||||
if err != nil {
|
||||
ctx.ServerError("ExitImpersonatedUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if exitedImpersonated {
|
||||
@@ -517,14 +517,14 @@ func prepareSignUpPageData(ctx *context.Context) bool {
|
||||
|
||||
hasUsers, err := user_model.HasUsers(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("HasUsers", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return false
|
||||
}
|
||||
ctx.Data["IsFirstTimeRegistration"] = !hasUsers.HasAnyUser
|
||||
|
||||
oauth2Providers, err := oauth2.GetOAuth2Providers(ctx, optional.Some(true))
|
||||
if err != nil {
|
||||
ctx.ServerError("GetOAuth2Providers", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return false
|
||||
}
|
||||
ctx.Data["OAuth2Providers"] = oauth2Providers
|
||||
@@ -640,16 +640,12 @@ func createUserInContext(ctx *context.Context, tpl templates.TplName, form any,
|
||||
user, err := user_model.GetIndividualUserByName(ctx, u.Name)
|
||||
if err != nil {
|
||||
if !user_model.IsErrUserNotExist(err) {
|
||||
ctx.ServerError("GetIndividualUserByName", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return false
|
||||
}
|
||||
user, err = user_model.GetIndividualUserByPrimaryEmail(ctx, u.Email)
|
||||
if err != nil {
|
||||
if !user_model.IsErrUserNotExist(err) {
|
||||
ctx.ServerError("GetIndividualUserByPrimaryEmail", err)
|
||||
} else {
|
||||
ctx.NotFound(err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -667,7 +663,7 @@ func createUserInContext(ctx *context.Context, tpl templates.TplName, form any,
|
||||
|
||||
// handle error without a template
|
||||
if len(tpl) == 0 {
|
||||
ctx.ServerError("CreateUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -696,7 +692,7 @@ func createUserInContext(ctx *context.Context, tpl templates.TplName, form any,
|
||||
ctx.Data["Err_UserName"] = true
|
||||
ctx.RenderWithErrDeprecated(ctx.Tr("user.form.name_chars_not_allowed", errNameCharsNotAllowed.Name), tpl, form)
|
||||
default:
|
||||
ctx.ServerError("CreateUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -711,7 +707,7 @@ func handleUserCreated(ctx *context.Context, u *user_model.User, possibleLinkAcc
|
||||
// Auto-set admin for the only user.
|
||||
hasUsers, err := user_model.HasUsers(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("HasUsers", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return false
|
||||
}
|
||||
if hasUsers.HasOnlyOneUser {
|
||||
@@ -722,7 +718,7 @@ func handleUserCreated(ctx *context.Context, u *user_model.User, possibleLinkAcc
|
||||
SetLastLogin: true,
|
||||
}
|
||||
if err := user_service.UpdateUser(ctx, u, opts); err != nil {
|
||||
ctx.ServerError("UpdateUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -878,21 +874,17 @@ func handleAccountActivation(ctx *context.Context, user *user_model.User) {
|
||||
user.IsActive = true
|
||||
var err error
|
||||
if user.Rands, err = user_model.GetUserSalt(); err != nil {
|
||||
ctx.ServerError("UpdateUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if err := user_model.UpdateUserCols(ctx, user, "is_active", "rands"); err != nil {
|
||||
if user_model.IsErrUserNotExist(err) {
|
||||
ctx.NotFound(err)
|
||||
} else {
|
||||
ctx.ServerError("UpdateUser", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := user_model.ActivateUserEmail(ctx, user.ID, user.Email, true); err != nil {
|
||||
log.Error("Unable to activate email for user: %-v with email: %s: %v", user, user.Email, err)
|
||||
ctx.ServerError("ActivateUserEmail", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -900,17 +892,17 @@ func handleAccountActivation(ctx *context.Context, user *user_model.User) {
|
||||
|
||||
if err := regenerateSession(ctx, map[string]any{session.KeyUID: user.ID}); err != nil {
|
||||
log.Error("Unable to regenerate session for user: %-v with email: %s: %v", user, user.Email, err)
|
||||
ctx.ServerError("ActivateUserEmail", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := resetLocale(ctx, user); err != nil {
|
||||
ctx.ServerError("resetLocale", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := user_service.UpdateUser(ctx, user, &user_service.UpdateOptions{SetLastLogin: true}); err != nil {
|
||||
ctx.ServerError("UpdateUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -926,7 +918,7 @@ func ActivateEmail(ctx *context.Context) {
|
||||
// Verify code.
|
||||
if email := user_model.VerifyActiveEmailCode(ctx, code, emailStr); email != nil {
|
||||
if err := user_model.ActivateEmail(ctx, email); err != nil {
|
||||
ctx.ServerError("ActivateEmail", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ func LinkAccount(ctx *context.Context) {
|
||||
|
||||
uname, err := extractUserNameFromOAuth2(&linkAccountData.GothUser)
|
||||
if err != nil {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
email := linkAccountData.GothUser.Email
|
||||
@@ -76,7 +76,7 @@ func LinkAccount(ctx *context.Context) {
|
||||
if email != "" {
|
||||
u, err := user_model.GetUserByEmail(ctx, email)
|
||||
if err != nil && !user_model.IsErrUserNotExist(err) {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if u != nil {
|
||||
@@ -85,7 +85,7 @@ func LinkAccount(ctx *context.Context) {
|
||||
} else if uname != "" {
|
||||
u, err := user_model.GetUserByName(ctx, uname)
|
||||
if err != nil && !user_model.IsErrUserNotExist(err) {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if u != nil {
|
||||
@@ -96,7 +96,7 @@ func LinkAccount(ctx *context.Context) {
|
||||
ctx.HTML(http.StatusOK, tplLinkAccount)
|
||||
}
|
||||
|
||||
func handleSignInError(ctx *context.Context, userName string, ptrForm any, tmpl templates.TplName, invoker string, err error) {
|
||||
func handleSignInError(ctx *context.Context, userName string, ptrForm any, tmpl templates.TplName, err error) {
|
||||
if errors.Is(err, util.ErrNotExist) {
|
||||
ctx.RenderWithErrDeprecated(ctx.Tr("form.username_password_incorrect"), tmpl, ptrForm)
|
||||
} else if errors.Is(err, util.ErrInvalidArgument) {
|
||||
@@ -108,7 +108,7 @@ func handleSignInError(ctx *context.Context, userName string, ptrForm any, tmpl
|
||||
ctx.Data["Title"] = ctx.Tr("auth.prohibit_login")
|
||||
ctx.HTML(http.StatusOK, "user/auth/prohibit_login")
|
||||
} else {
|
||||
ctx.ServerError(invoker, err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ func LinkAccountPostSignIn(ctx *context.Context) {
|
||||
|
||||
linkAccountData := oauth2GetLinkAccountData(ctx)
|
||||
if linkAccountData == nil {
|
||||
ctx.ServerError("UserSignIn", errors.New("not in LinkAccount session"))
|
||||
ctx.ServerErrorAuto(errors.New("not in LinkAccount session"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ func LinkAccountPostSignIn(ctx *context.Context) {
|
||||
|
||||
u, _, err := auth_service.UserSignIn(ctx, signInForm.UserName, signInForm.Password)
|
||||
if err != nil {
|
||||
handleSignInError(ctx, signInForm.UserName, &signInForm, tplLinkAccount, "UserLinkAccount", err)
|
||||
handleSignInError(ctx, signInForm.UserName, &signInForm, tplLinkAccount, err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -151,12 +151,12 @@ func oauth2LinkAccount(ctx *context.Context, u *user_model.User, linkAccountData
|
||||
// We deliberately ignore the skip local 2fa setting here because we are linking to a previous user here
|
||||
hasTwoFactor, err := auth.HasTwoFactorOrWebAuthn(ctx, u.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("UserLinkAccount", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if !hasTwoFactor {
|
||||
if err := externalaccount.LinkAccountToUser(ctx, linkAccountData.AuthSourceID, u, linkAccountData.GothUser); err != nil {
|
||||
ctx.ServerError("UserLinkAccount", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ func oauth2LinkAccount(ctx *context.Context, u *user_model.User, linkAccountData
|
||||
}
|
||||
|
||||
if err := Oauth2SetLinkAccountData(ctx, *linkAccountData); err != nil {
|
||||
ctx.ServerError("Oauth2SetLinkAccountData", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ func LinkAccountPostRegister(ctx *context.Context) {
|
||||
|
||||
linkAccountData := oauth2GetLinkAccountData(ctx)
|
||||
if linkAccountData == nil {
|
||||
ctx.ServerError("UserSignUp", errors.New("not in LinkAccount session"))
|
||||
ctx.ServerErrorAuto(errors.New("not in LinkAccount session"))
|
||||
return
|
||||
}
|
||||
if ctx.HasError() {
|
||||
@@ -250,12 +250,12 @@ func LinkAccountPostRegister(ctx *context.Context) {
|
||||
|
||||
authSource, err := auth.GetSourceByID(ctx, linkAccountData.AuthSourceID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetSourceByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
source := auth.MustSourceCfg[*oauth2.Source](authSource)
|
||||
if err := syncGroupsToTeams(ctx, source, &linkAccountData.GothUser, u); err != nil {
|
||||
ctx.ServerError("SyncGroupsToTeams", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+21
-21
@@ -42,7 +42,7 @@ func SignInOAuth(ctx *context.Context) {
|
||||
authName := ctx.PathParam("provider")
|
||||
authSource, err := auth.GetActiveOAuth2SourceByAuthName(ctx, authName)
|
||||
if err != nil {
|
||||
ctx.ServerError("SignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -61,15 +61,15 @@ func SignInOAuth(ctx *context.Context) {
|
||||
if err = oauth2Source.Callout(ctx.Req, ctx.Resp); err != nil {
|
||||
if strings.Contains(err.Error(), "no provider for ") {
|
||||
if err = oauth2.ResetOAuth2(ctx); err != nil {
|
||||
ctx.ServerError("SignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if err = oauth2Source.Callout(ctx.Req, ctx.Resp); err != nil {
|
||||
ctx.ServerError("SignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
ctx.ServerError("SignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
// redirect is done in oauth2.Auth
|
||||
}
|
||||
@@ -91,12 +91,12 @@ func SignInOAuthCallback(ctx *context.Context) {
|
||||
authName := ctx.PathParam("provider")
|
||||
authSource, err := auth.GetActiveOAuth2SourceByAuthName(ctx, authName)
|
||||
if err != nil {
|
||||
ctx.ServerError("SignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if authSource == nil {
|
||||
ctx.ServerError("SignIn", errors.New("no valid provider found, check configured callback url in provider"))
|
||||
ctx.ServerErrorAuto(errors.New("no valid provider found, check configured callback url in provider"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ func SignInOAuthCallback(ctx *context.Context) {
|
||||
ctx.Redirect(setting.AppSubURL + "/user/login")
|
||||
return
|
||||
}
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ func SignInOAuthCallback(ctx *context.Context) {
|
||||
// attach user to the current signed-in user
|
||||
err = externalaccount.LinkAccountToUser(ctx, authSource.ID, ctx.Doer, gothUser)
|
||||
if err != nil {
|
||||
ctx.ServerError("UserLinkAccount", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ func SignInOAuthCallback(ctx *context.Context) {
|
||||
}
|
||||
uname, err := extractUserNameFromOAuth2(&gothUser)
|
||||
if err != nil {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if uname == "" {
|
||||
@@ -201,7 +201,7 @@ func SignInOAuthCallback(ctx *context.Context) {
|
||||
}
|
||||
|
||||
if err := syncGroupsToTeams(ctx, source, &gothUser, u); err != nil {
|
||||
ctx.ServerError("SyncGroupsToTeams", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@@ -293,7 +293,7 @@ func Oauth2SetLinkAccountData(ctx *context.Context, linkAccountData LinkAccountD
|
||||
|
||||
func showLinkingLogin(ctx *context.Context, authSourceID int64, gothUser goth.User) {
|
||||
if err := Oauth2SetLinkAccountData(ctx, LinkAccountData{authSourceID, gothUser}); err != nil {
|
||||
ctx.ServerError("Oauth2SetLinkAccountData", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Redirect(setting.AppSubURL + "/user/link_account")
|
||||
@@ -353,7 +353,7 @@ func handleOAuth2SignIn(ctx *context.Context, authSource *auth.Source, u *user_m
|
||||
if !authSource.TwoFactorShouldSkip() {
|
||||
var err error
|
||||
if needs2FA, err = auth.HasTwoFactorOrWebAuthn(ctx, u.ID); err != nil {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -362,7 +362,7 @@ func handleOAuth2SignIn(ctx *context.Context, authSource *auth.Source, u *user_m
|
||||
|
||||
groupTeamMapping, err := auth_module.UnmarshalGroupTeamMapping(oauth2Source.GroupTeamMap)
|
||||
if err != nil {
|
||||
ctx.ServerError("UnmarshalGroupTeamMapping", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -378,7 +378,7 @@ func handleOAuth2SignIn(ctx *context.Context, authSource *auth.Source, u *user_m
|
||||
if !u.IsActive {
|
||||
extLogin, hasExt, err := user_model.GetExternalLogin(ctx, authSource.ID, gothUser.UserID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetExternalLogin", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
// the cron clears all three token fields when it disables a user, so require the
|
||||
@@ -392,13 +392,13 @@ func handleOAuth2SignIn(ctx *context.Context, authSource *auth.Source, u *user_m
|
||||
|
||||
if oauth2Source.GroupTeamMap != "" || oauth2Source.GroupTeamMapRemoval {
|
||||
if err := source_service.SyncGroupsToTeams(ctx, u, groups, groupTeamMapping, oauth2Source.GroupTeamMapRemoval); err != nil {
|
||||
ctx.ServerError("SyncGroupsToTeams", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if err := externalaccount.EnsureLinkExternalToUser(ctx, authSource.ID, u, gothUser); err != nil {
|
||||
ctx.ServerError("EnsureLinkExternalToUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -409,12 +409,12 @@ func handleOAuth2SignIn(ctx *context.Context, authSource *auth.Source, u *user_m
|
||||
opts.SetLastLogin = true
|
||||
|
||||
if err := user_service.UpdateUser(audit.WithDoer(ctx, user_model.NewAuthSourceUser()), u, opts); err != nil {
|
||||
ctx.ServerError("UpdateUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
userHasTwoFactorAuth, err := auth.HasTwoFactorOrWebAuthn(ctx, u.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("UpdateUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -423,12 +423,12 @@ func handleOAuth2SignIn(ctx *context.Context, authSource *auth.Source, u *user_m
|
||||
session.KeyUserHasTwoFactorAuth: userHasTwoFactorAuth,
|
||||
session.KeySignInMethod: session.SignInMethodOAuth2,
|
||||
}); err != nil {
|
||||
ctx.ServerError("updateSession", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := resetLocale(ctx, u); err != nil {
|
||||
ctx.ServerError("resetLocale", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -438,7 +438,7 @@ func handleOAuth2SignIn(ctx *context.Context, authSource *auth.Source, u *user_m
|
||||
|
||||
if opts.IsActive.Has() || opts.IsAdmin.Has() || opts.IsRestricted.Has() {
|
||||
if err := user_service.UpdateUser(audit.WithDoer(ctx, user_model.NewAuthSourceUser()), u, opts); err != nil {
|
||||
ctx.ServerError("UpdateUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ func InfoOAuth(ctx *context.Context) {
|
||||
// are unaffected and only explicitly-restricted tokens are rejected
|
||||
tokenScope, _ := user_model.GetDoerTokenScope(ctx.Doer)
|
||||
if allowed, err := tokenScope.HasScope(auth.AccessTokenScopeReadUser); err != nil {
|
||||
ctx.ServerError("HasScope", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
} else if !allowed {
|
||||
ctx.Resp.Header().Set("WWW-Authenticate", `Bearer realm="Gitea OAuth2"`)
|
||||
@@ -123,7 +123,7 @@ func InfoOAuth(ctx *context.Context) {
|
||||
|
||||
groups, err := oauth2_provider.GetOAuthGroupsForUser(ctx, ctx.Doer, user_model.IsPublicOnlyDoer(ctx.Doer))
|
||||
if err != nil {
|
||||
ctx.ServerError("Oauth groups for user", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
response.Groups = groups
|
||||
@@ -185,7 +185,7 @@ func IntrospectOAuth(ctx *context.Context) {
|
||||
|
||||
grant, err := auth.GetOAuth2GrantByID(ctx, token.GrantID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetOAuth2GrantByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if grant == nil || grant.ApplicationID != introspectingApp.ID || (token.Kind == oauth2_provider.KindRefreshToken && isRefreshTokenUsed(grant, token)) {
|
||||
@@ -201,7 +201,7 @@ func IntrospectOAuth(ctx *context.Context) {
|
||||
response.RegisteredClaims = oauth2_provider.NewJwtRegisteredClaimsFromUser(introspectingApp.ClientID, grant.UserID, nil /*exp*/)
|
||||
response.Username = user.Name
|
||||
} else if !errors.Is(err, util.ErrNotExist) && !errors.Is(err, util.ErrPermissionDenied) {
|
||||
ctx.ServerError("GetValidDoerUserByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ func AuthorizeOAuth(ctx *context.Context) {
|
||||
}, "")
|
||||
return
|
||||
}
|
||||
ctx.ServerError("GetOAuth2ApplicationByClientID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ func AuthorizeOAuth(ctx *context.Context) {
|
||||
if app.UID != 0 {
|
||||
user, err = user_model.GetUserByID(ctx, app.UID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetUserByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -425,7 +425,7 @@ func GrantApplicationOAuth(ctx *context.Context) {
|
||||
|
||||
app, err := auth.GetOAuth2ApplicationByClientID(ctx, form.ClientID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetOAuth2ApplicationByClientID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
grant, err := app.GetGrantByUserID(ctx, ctx.Doer.ID)
|
||||
@@ -744,7 +744,7 @@ func handleAuthorizeError(ctx *context.Context, authErr AuthorizeError, redirect
|
||||
}
|
||||
redirect, err := url.Parse(redirectURI)
|
||||
if err != nil {
|
||||
ctx.ServerError("url.Parse", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
q := redirect.Query()
|
||||
|
||||
@@ -25,12 +25,12 @@ func oauth2SignInSync(ctx *context.Context, authSourceID int64, u *user_model.Us
|
||||
|
||||
authSource, err := auth.GetSourceByID(ctx, authSourceID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetSourceByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
oauth2Source, _ := authSource.Cfg.(*oauth2.Source)
|
||||
if !authSource.IsOAuth2() || oauth2Source == nil {
|
||||
ctx.ServerError("oauth2SignInSync", fmt.Errorf("source %s is not an OAuth2 source", gothUser.Provider))
|
||||
ctx.ServerErrorAuto(fmt.Errorf("source %s is not an OAuth2 source", gothUser.Provider))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ func ForgotPasswdPost(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("auth.forgot_password_title")
|
||||
|
||||
if setting.MailService == nil {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
ctx.Data["IsResetRequest"] = true
|
||||
@@ -75,7 +75,7 @@ func ForgotPasswdPost(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
ctx.ServerError("user.ResetPasswd(check existence)", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ func ResetPasswdPost(ctx *context.Context) {
|
||||
case password.IsErrIsPwnedRequest(err):
|
||||
ctx.RenderWithErrDeprecated(ctx.Tr("auth.password_pwned_err"), tplResetPassword, nil)
|
||||
default:
|
||||
ctx.ServerError("UpdateAuth", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -234,11 +234,11 @@ func ResetPasswdPost(ctx *context.Context) {
|
||||
// Invalidate the scratch token.
|
||||
_, err := twofa.GenerateScratchToken()
|
||||
if err != nil {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if err = auth.UpdateTwoFactor(ctx, twofa); err != nil {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ func ResetPasswdPost(ctx *context.Context) {
|
||||
if twofa == nil {
|
||||
hasWebAuthn, err := auth.HasWebAuthnRegistrationsByUID(ctx, u.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("HasWebAuthnRegistrationsByUID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if hasWebAuthn {
|
||||
@@ -288,7 +288,7 @@ func MustChangePasswordPost(ctx *context.Context) {
|
||||
|
||||
if !common.CheckSignedInUser(ctx.Doer, ctx.Session).NeedChangePassword {
|
||||
log.Debug("User %s attempted to access the must change password page, but they are not required to change their password", ctx.Doer.Name)
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ func MustChangePasswordPost(ctx *context.Context) {
|
||||
ctx.Data["Err_Password"] = true
|
||||
ctx.RenderWithErrDeprecated(ctx.Tr("auth.password_pwned_err"), tplMustChangePassword, &form)
|
||||
default:
|
||||
ctx.ServerError("UpdateAuth", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -33,13 +33,13 @@ func WebAuthn(ctx *context.Context) {
|
||||
// Ensure user is in a 2FA session.
|
||||
idSess, ok := ctx.Session.Get("twofaUid").(int64)
|
||||
if !ok {
|
||||
ctx.ServerError("UserSignIn", errors.New("not in WebAuthn session"))
|
||||
ctx.ServerErrorAuto(errors.New("not in WebAuthn session"))
|
||||
return
|
||||
}
|
||||
|
||||
hasTwoFactor, err := auth.HasTwoFactorByUID(ctx, idSess)
|
||||
if err != nil {
|
||||
ctx.ServerError("HasTwoFactorByUID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -58,12 +58,12 @@ func WebAuthnPasskeyAssertion(ctx *context.Context) {
|
||||
// a passkey is the only factor here
|
||||
assertion, sessionData, err := wa.WebAuthn.BeginDiscoverableLogin(webauthn.WithUserVerification(protocol.VerificationRequired))
|
||||
if err != nil {
|
||||
ctx.ServerError("webauthn.BeginDiscoverableLogin", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := ctx.Session.Set("webauthnPasskeyAssertion", sessionData); err != nil {
|
||||
ctx.ServerError("Session.Set", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ func WebAuthnPasskeyLogin(ctx *context.Context) {
|
||||
|
||||
sessionData, okData := ctx.Session.Get("webauthnPasskeyAssertion").(*webauthn.SessionData)
|
||||
if !okData || sessionData == nil {
|
||||
ctx.ServerError("ctx.Session.Get", errors.New("not in WebAuthn session"))
|
||||
ctx.ServerErrorAuto(errors.New("not in WebAuthn session"))
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
@@ -139,18 +139,18 @@ func WebAuthnPasskeyLogin(ctx *context.Context) {
|
||||
// Success! Get the credential and update the sign count with the new value we received.
|
||||
dbCred, err := auth.GetWebAuthnCredentialByCredID(ctx, user.ID, cred.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetWebAuthnCredentialByCredID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
dbCred.SignCount = cred.Authenticator.SignCount
|
||||
if err := dbCred.UpdateSignCount(ctx); err != nil {
|
||||
ctx.ServerError("UpdateSignCount", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := completePendingLinks(ctx, user); err != nil {
|
||||
ctx.ServerError("completePendingLinks", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -164,23 +164,23 @@ func WebAuthnLoginAssertion(ctx *context.Context) {
|
||||
// Ensure user is in a WebAuthn session.
|
||||
idSess, ok := ctx.Session.Get("twofaUid").(int64)
|
||||
if !ok || idSess == 0 {
|
||||
ctx.ServerError("UserSignIn", errors.New("not in WebAuthn session"))
|
||||
ctx.ServerErrorAuto(errors.New("not in WebAuthn session"))
|
||||
return
|
||||
}
|
||||
|
||||
user, err := user_model.GetUserByID(ctx, idSess)
|
||||
if err != nil {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
exists, err := auth.ExistsWebAuthnCredentialsForUID(ctx, user.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if !exists {
|
||||
ctx.ServerError("UserSignIn", errors.New("no device registered"))
|
||||
ctx.ServerErrorAuto(errors.New("no device registered"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -188,12 +188,12 @@ func WebAuthnLoginAssertion(ctx *context.Context) {
|
||||
// "discouraged" would hide credProtect protected credentials
|
||||
assertion, sessionData, err := wa.WebAuthn.BeginLogin(webAuthnUser, webauthn.WithUserVerification(protocol.VerificationPreferred))
|
||||
if err != nil {
|
||||
ctx.ServerError("webauthn.BeginLogin", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := ctx.Session.Set("webauthnAssertion", sessionData); err != nil {
|
||||
ctx.ServerError("Session.Set", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK, assertion)
|
||||
@@ -204,7 +204,7 @@ func WebAuthnLoginAssertionPost(ctx *context.Context) {
|
||||
idSess, ok := ctx.Session.Get("twofaUid").(int64)
|
||||
sessionData, okData := ctx.Session.Get("webauthnAssertion").(*webauthn.SessionData)
|
||||
if !ok || !okData || sessionData == nil || idSess == 0 {
|
||||
ctx.ServerError("UserSignIn", errors.New("not in WebAuthn session"))
|
||||
ctx.ServerErrorAuto(errors.New("not in WebAuthn session"))
|
||||
return
|
||||
}
|
||||
defer func() {
|
||||
@@ -214,7 +214,7 @@ func WebAuthnLoginAssertionPost(ctx *context.Context) {
|
||||
// Load the user from the db
|
||||
user, err := user_model.GetUserByID(ctx, idSess)
|
||||
if err != nil {
|
||||
ctx.ServerError("UserSignIn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -251,18 +251,18 @@ func WebAuthnLoginAssertionPost(ctx *context.Context) {
|
||||
// Success! Get the credential and update the sign count with the new value we received.
|
||||
dbCred, err := auth.GetWebAuthnCredentialByCredID(ctx, user.ID, cred.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetWebAuthnCredentialByCredID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
dbCred.SignCount = cred.Authenticator.SignCount
|
||||
if err := dbCred.UpdateSignCount(ctx); err != nil {
|
||||
ctx.ServerError("UpdateSignCount", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := completePendingLinks(ctx, user); err != nil {
|
||||
ctx.ServerError("completePendingLinks", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import (
|
||||
func List(ctx *context.Context) {
|
||||
templateNames, err := templates.AssetFS().ListFiles("devtest", true)
|
||||
if err != nil {
|
||||
ctx.ServerError("AssetFS().ListFiles", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
var subNames []string
|
||||
@@ -150,7 +150,7 @@ func prepareMockDataBadgeActionsSvg(ctx *context.Context) {
|
||||
err = fmt.Errorf("unknown badge style: %s", selectedStyle)
|
||||
}
|
||||
if err != nil {
|
||||
ctx.ServerError("RenderToHTML", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
badgeSVGs = append(badgeSVGs, h)
|
||||
@@ -218,13 +218,13 @@ func prepareMockDataAvatarStack(ctx *context.Context) {
|
||||
func prepareMockDataMarkdown(ctx *context.Context) {
|
||||
content, err := templates.AssetFS().ReadFile("devtest/markdown.md")
|
||||
if err != nil {
|
||||
ctx.ServerError("ReadFile", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
rctx := markup.NewRenderContext(ctx).WithMetas(markup.ComposeSimpleDocumentMetas()).WithEnableHeadingIDGeneration(true)
|
||||
ctx.Data["MarkdownHTML"], err = markdown.RenderString(rctx, string(content))
|
||||
if err != nil {
|
||||
ctx.ServerError("RenderString", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ func MailPreviewRender(ctx *context.Context) {
|
||||
func MailPreviewEmbed(ctx *context.Context) {
|
||||
content, err := mailer.LoadMailIcon(ctx.PathParam("*"))
|
||||
if err != nil {
|
||||
ctx.NotFound(err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Resp.Header().Set("Content-Type", "image/png")
|
||||
|
||||
@@ -60,7 +60,7 @@ func Code(ctx *context.Context) {
|
||||
if ctx.Doer == nil || !isAdmin {
|
||||
repoIDs, err = repo_model.FindUserCodeAccessibleRepoIDs(ctx, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("FindUserCodeAccessibleRepoIDs", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@ func Code(ctx *context.Context) {
|
||||
})
|
||||
if err != nil {
|
||||
if code_indexer.IsAvailable(ctx) {
|
||||
ctx.ServerError("SearchResults", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["CodeIndexerUnavailable"] = true
|
||||
@@ -101,7 +101,7 @@ func Code(ctx *context.Context) {
|
||||
|
||||
repoMaps, err := repo_model.GetRepositoriesMapByIDs(ctx, loadRepoIDs)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRepositoriesMapByIDs", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
|
||||
IsPrivate: private,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchRepository", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if isSitemap {
|
||||
|
||||
@@ -83,7 +83,7 @@ func RenderUserSearch(ctx *context.Context, opts user_model.SearchUserOptions, t
|
||||
}
|
||||
|
||||
if opts.SupportedSortOrders != nil && !opts.SupportedSortOrders.Contains(sortOrder) {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ func RenderUserSearch(ctx *context.Context, opts user_model.SearchUserOptions, t
|
||||
if len(opts.Keyword) == 0 || isKeywordValid(opts.Keyword) {
|
||||
users, count, err = user_model.SearchUsers(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchUsers", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ func showBranchFeed(ctx *context.Context, repo *repo.Repository, formatType stri
|
||||
if ctx.Repo.Commit != nil {
|
||||
commits, err = ctx.Repo.Commit.CommitsByRange(ctx, ctx.Repo.GitRepo, 0, 10, "", "", "")
|
||||
if err != nil {
|
||||
ctx.ServerError("ShowBranchFeed", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ func showFileFeed(ctx *context.Context, repo *repo.Repository, formatType string
|
||||
Page: 1,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("ShowBranchFeed", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ func ShowUserFeedAtom(ctx *context.Context) {
|
||||
// showUserFeed show user activity as RSS / Atom feed
|
||||
func showUserFeed(ctx *context.Context, formatType string) {
|
||||
if !setting.Other.EnableFeed {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
context.CheckTokenScopes(ctx, util.Iif(ctx.ContextUser.IsOrganization(), auth_model.AccessTokenScopeReadOrganization, auth_model.AccessTokenScopeReadUser))
|
||||
@@ -46,7 +46,7 @@ func showUserFeed(ctx *context.Context, formatType string) {
|
||||
// include the private repo's the member has access to.
|
||||
isOrgMember, err := organization.IsOrganizationMember(ctx, ctx.ContextUser.ID, ctx.Doer.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("IsOrganizationMember", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
includePrivate = isOrgMember
|
||||
@@ -61,7 +61,7 @@ func showUserFeed(ctx *context.Context, formatType string) {
|
||||
Date: ctx.FormString("date"),
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetFeeds", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ func showUserFeed(ctx *context.Context, formatType string) {
|
||||
ctxUserDescription, err := markdown.RenderString(rctx,
|
||||
ctx.ContextUser.Description)
|
||||
if err != nil {
|
||||
ctx.ServerError("RenderString", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ func showUserFeed(ctx *context.Context, formatType string) {
|
||||
|
||||
feed.Items, err = feedActionsToFeedItems(ctx, actions)
|
||||
if err != nil {
|
||||
ctx.ServerError("convert feed", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -94,12 +94,12 @@ func writeFeed(ctx *context.Context, feed *feeds.Feed, formatType string) {
|
||||
if formatType == "atom" {
|
||||
ctx.Resp.Header().Set("Content-Type", ContentTypeAtomXml+"; charset=utf-8")
|
||||
if err := feed.WriteAtom(ctx.Resp); err != nil {
|
||||
ctx.ServerError("Render Atom failed", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
} else {
|
||||
ctx.Resp.Header().Set("Content-Type", ContentTypeRssXml+"; charset=utf-8")
|
||||
if err := feed.WriteRss(ctx.Resp); err != nil {
|
||||
ctx.ServerError("Render RSS failed", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ func ShowReleaseFeed(ctx *context.Context, repo *repo_model.Repository, isReleas
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetReleasesByRepoID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ func ShowReleaseFeed(ctx *context.Context, repo *repo_model.Repository, isReleas
|
||||
|
||||
feed.Items, err = releasesToFeedItems(ctx, releases)
|
||||
if err != nil {
|
||||
ctx.ServerError("releasesToFeedItems", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ func ShowRepoFeed(ctx *context.Context, repo *repo_model.Repository, formatType
|
||||
Date: ctx.FormString("date"),
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetFeeds", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func ShowRepoFeed(ctx *context.Context, repo *repo_model.Repository, formatType
|
||||
|
||||
feed.Items, err = feedActionsToFeedItems(ctx, actions)
|
||||
if err != nil {
|
||||
ctx.ServerError("convert feed", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -60,7 +60,7 @@ func HomeSitemap(ctx *context.Context) {
|
||||
Visible: []structs.VisibleType{structs.VisibleTypePublic},
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchUsers", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
count := int(cnt)
|
||||
@@ -79,7 +79,7 @@ func HomeSitemap(ctx *context.Context) {
|
||||
AllPublic: true,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchRepository", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
count := int(cnt)
|
||||
|
||||
@@ -21,7 +21,7 @@ func BlockedUsers(ctx *context.Context) {
|
||||
ctx.Data["PageIsSettingsBlockedUsers"] = true
|
||||
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ func orgHome(ctx *context.Context, viewRepositories bool) {
|
||||
org := ctx.Org.Organization
|
||||
if org == nil {
|
||||
// some requests may reach here by "user" route patterns, e.g.: "/{owner}/-/repositories"
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ func orgHome(ctx *context.Context, viewRepositories bool) {
|
||||
|
||||
members, _, err := organization.FindOrgMembers(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.ServerError("FindOrgMembers", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ func orgHome(ctx *context.Context, viewRepositories bool) {
|
||||
ListOptions: db.ListOptions{Page: 1, PageSize: orgOverviewTeamsLimit},
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchTeam", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -122,7 +122,7 @@ func orgHome(ctx *context.Context, viewRepositories bool) {
|
||||
|
||||
prepareResult, err := shared_user.RenderUserOrgHeader(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ func orgHome(ctx *context.Context, viewRepositories bool) {
|
||||
IsPrivate: private,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchRepository", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ func Members(ctx *context.Context) {
|
||||
if ctx.Doer != nil {
|
||||
isMember, err := ctx.Org.Organization.IsOrgMember(ctx, ctx.Doer.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("IsOrgMember", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
opts.IsDoerMember = isMember
|
||||
@@ -51,12 +51,12 @@ func Members(ctx *context.Context) {
|
||||
|
||||
total, err := organization.CountOrgMembers(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.ServerError("CountOrgMembers", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func Members(ctx *context.Context) {
|
||||
opts.ListOptions.PageSize = pageSize
|
||||
members, membersIsPublic, err := organization.FindOrgMembers(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetMembers", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Page"] = pager
|
||||
@@ -85,7 +85,7 @@ func MembersAction(ctx *context.Context) {
|
||||
ctx.HTTPError(http.StatusNotFound)
|
||||
return
|
||||
} else if err != nil {
|
||||
ctx.ServerError("GetUserByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -27,14 +27,14 @@ func GetMentionsInOwner(ctx *context.Context) {
|
||||
// Get org members
|
||||
members, _, err := org.GetMembers(ctx, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetMembers", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
c.AddUsers(ctx, members)
|
||||
|
||||
// Get mentionable teams
|
||||
if err := c.AddMentionableTeams(ctx, ctx.Doer, ctx.ContextUser); err != nil {
|
||||
ctx.ServerError("AddMentionableTeams", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ const (
|
||||
func Create(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("new_org")
|
||||
if !ctx.Doer.CanCreateOrganization() {
|
||||
ctx.ServerError("Not allowed", errors.New(ctx.Locale.TrString("org.form.create_org_not_allowed")))
|
||||
ctx.ServerErrorAuto(errors.New(ctx.Locale.TrString("org.form.create_org_not_allowed")))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ func CreatePost(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("new_org")
|
||||
|
||||
if !ctx.Doer.CanCreateOrganization() {
|
||||
ctx.ServerError("Not allowed", errors.New(ctx.Locale.TrString("org.form.create_org_not_allowed")))
|
||||
ctx.ServerErrorAuto(errors.New(ctx.Locale.TrString("org.form.create_org_not_allowed")))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ func CreatePost(ctx *context.Context) {
|
||||
case organization.IsErrUserNotAllowedCreateOrg(err):
|
||||
ctx.RenderWithErrDeprecated(ctx.Tr("org.form.create_org_not_allowed"), tplCreateOrg, &form)
|
||||
default:
|
||||
ctx.ServerError("CreateOrganization", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
func RetrieveLabels(ctx *context.Context) {
|
||||
labels, err := issues_model.GetLabelsByOrgID(ctx, ctx.Org.Organization.ID, ctx.FormString("sort"), db.ListOptions{})
|
||||
if err != nil {
|
||||
ctx.ServerError("RetrieveLabels.GetLabels", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
for _, l := range labels {
|
||||
@@ -48,7 +48,7 @@ func NewLabel(ctx *context.Context) {
|
||||
ExclusiveOrder: form.ExclusiveOrder,
|
||||
}
|
||||
if err := issues_model.NewLabel(ctx, l); err != nil {
|
||||
ctx.ServerError("NewLabel", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.JSONRedirect(ctx.Org.OrgLink + "/settings/labels")
|
||||
@@ -66,7 +66,7 @@ func UpdateLabel(ctx *context.Context) {
|
||||
ctx.JSONErrorNotFound()
|
||||
return
|
||||
} else if err != nil {
|
||||
ctx.ServerError("GetLabelInOrgByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ func UpdateLabel(ctx *context.Context) {
|
||||
l.Color = form.Color
|
||||
l.SetArchived(form.IsArchived)
|
||||
if err := issues_model.UpdateLabel(ctx, l); err != nil {
|
||||
ctx.ServerError("UpdateLabel", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.JSONRedirect(ctx.Org.OrgLink + "/settings/labels")
|
||||
@@ -108,7 +108,7 @@ func InitializeLabels(ctx *context.Context) {
|
||||
ctx.Redirect(ctx.Org.OrgLink + "/settings/labels")
|
||||
return
|
||||
}
|
||||
ctx.ServerError("InitializeLabels", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Redirect(ctx.Org.OrgLink + "/settings/labels")
|
||||
|
||||
+26
-26
@@ -39,7 +39,7 @@ const (
|
||||
// Projects renders the home page of projects
|
||||
func Projects(ctx *context.Context) {
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Title"] = ctx.Tr("repo.projects")
|
||||
@@ -68,12 +68,12 @@ func Projects(ctx *context.Context) {
|
||||
Title: keyword,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("FindProjects", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := project_service.LoadIssueNumbersForProjects(ctx, projects, ctx.Doer); err != nil {
|
||||
ctx.ServerError("LoadIssueNumbersForProjects", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ func Projects(ctx *context.Context) {
|
||||
Type: projectType,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("CountProjects", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ func RenderNewProject(ctx *context.Context) {
|
||||
ctx.Data["HomeLink"] = ctx.ContextUser.HomeLink()
|
||||
ctx.Data["CancelLink"] = ctx.ContextUser.HomeLink() + "/-/projects"
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ func NewProjectPost(ctx *context.Context) {
|
||||
form := web.GetForm[*forms.CreateProjectForm](ctx)
|
||||
ctx.Data["Title"] = ctx.Tr("repo.projects.new")
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ func NewProjectPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
if err := project_model.NewProject(ctx, &newProject); err != nil {
|
||||
ctx.ServerError("NewProject", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
audit.Record(ctx, audit_model.ProjectCreate, ctx.ContextUser, "project", newProject.Title, "project_id", newProject.ID)
|
||||
@@ -197,12 +197,12 @@ func ChangeProjectStatus(ctx *context.Context) {
|
||||
|
||||
project, err := project_model.GetProjectByIDAndOwner(ctx, id, ctx.ContextUser.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetProjectByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := project_model.ChangeProjectStatusByRepoIDAndID(ctx, 0, project.ID, toClose); err != nil {
|
||||
ctx.ServerError("ChangeProjectStatusByRepoIDAndID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.JSONRedirect(project_model.ProjectLinkForOrg(ctx.ContextUser, project.ID))
|
||||
@@ -212,7 +212,7 @@ func ChangeProjectStatus(ctx *context.Context) {
|
||||
func DeleteProject(ctx *context.Context) {
|
||||
p, err := project_model.GetProjectByIDAndOwner(ctx, ctx.PathParamInt64("id"), ctx.ContextUser.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetProjectByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -235,13 +235,13 @@ func RenderEditProject(ctx *context.Context) {
|
||||
ctx.Data["CardTypes"] = project_model.GetCardConfig()
|
||||
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
p, err := project_model.GetProjectByIDAndOwner(ctx, ctx.PathParamInt64("id"), ctx.ContextUser.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetProjectByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ func EditProjectPost(ctx *context.Context) {
|
||||
ctx.Data["CancelLink"] = project_model.ProjectLinkForOrg(ctx.ContextUser, projectID)
|
||||
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ func EditProjectPost(ctx *context.Context) {
|
||||
|
||||
p, err := project_model.GetProjectByIDAndOwner(ctx, projectID, ctx.ContextUser.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetProjectByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ func EditProjectPost(ctx *context.Context) {
|
||||
p.Description = form.Content
|
||||
p.CardType = form.CardType
|
||||
if err = project_model.UpdateProject(ctx, p); err != nil {
|
||||
ctx.ServerError("UpdateProjects", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
audit.Record(ctx, audit_model.ProjectUpdate, ctx.ContextUser, "project", p.Title, "project_id", p.ID)
|
||||
@@ -304,18 +304,18 @@ func EditProjectPost(ctx *context.Context) {
|
||||
func ViewProject(ctx *context.Context) {
|
||||
project, err := project_model.GetProjectByIDAndOwner(ctx, ctx.PathParamInt64("id"), ctx.ContextUser.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetProjectByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := project.LoadOwner(ctx); err != nil {
|
||||
ctx.ServerError("LoadOwner", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
columns, err := project_model.GetColumns(ctx, project.ID, db.ListOptionsAll)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetColumns", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ func ViewProject(ctx *context.Context) {
|
||||
|
||||
issuesMap, err := project_service.LoadIssuesFromProject(ctx, project, &opts)
|
||||
if err != nil {
|
||||
ctx.ServerError("LoadIssuesOfColumns", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
for _, column := range columns {
|
||||
@@ -369,14 +369,14 @@ func ViewProject(ctx *context.Context) {
|
||||
|
||||
linkedPrsMap, err := project_service.LoadLinkedPullRequests(ctx, issuesMap, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("LoadLinkedPullRequests", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: Add option to filter also by repository specific labels
|
||||
labels, err := issues_model.GetLabelsByOrgID(ctx, project.OwnerID, "", db.ListOptions{})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetLabelsByOrgID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ func ViewProject(ctx *context.Context) {
|
||||
RepoID: project.RepoID,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRepoMilestones", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@@ -424,7 +424,7 @@ func ViewProject(ctx *context.Context) {
|
||||
ProjectID: project.ID,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetOrgMilestones", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -437,7 +437,7 @@ func ViewProject(ctx *context.Context) {
|
||||
// Get assignees.
|
||||
assigneeUsers, err := project_service.LoadIssuesAssigneesForProject(ctx, project.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("LoadIssuesAssigneesForProject", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Assignees"] = shared_user.MakeSelfOnTop(ctx.Doer, assigneeUsers)
|
||||
@@ -453,7 +453,7 @@ func ViewProject(ctx *context.Context) {
|
||||
ctx.Data["Title"] = fmt.Sprintf("%s - %s", project.Title, ctx.ContextUser.DisplayName())
|
||||
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -463,7 +463,7 @@ func ViewProject(ctx *context.Context) {
|
||||
// ProjectWorkflows renders the workflows page of an owner-level project
|
||||
func ProjectWorkflows(ctx *context.Context) {
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["PageIsViewProjects"] = true
|
||||
|
||||
@@ -50,7 +50,7 @@ func Settings(ctx *context.Context) {
|
||||
ctx.Data["ContextUser"] = ctx.ContextUser
|
||||
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ func SettingsPost(ctx *context.Context) {
|
||||
ctx.RenderWithErrDeprecated(ctx.Tr("form.email_invalid"), tplSettingsOptions, &form)
|
||||
return
|
||||
}
|
||||
ctx.ServerError("UpdateOrgEmailAddress", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ func SettingsPost(ctx *context.Context) {
|
||||
}
|
||||
|
||||
if err := user_service.UpdateUser(ctx, org.AsUser(), opts); err != nil {
|
||||
ctx.ServerError("UpdateUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -158,12 +158,12 @@ func Webhooks(ctx *context.Context) {
|
||||
|
||||
ws, err := db.Find[webhook.Webhook](ctx, webhook.ListWebhookOptions{OwnerID: ctx.Org.Organization.ID})
|
||||
if err != nil {
|
||||
ctx.ServerError("ListWebhooksByOpts", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ func Labels(ctx *context.Context) {
|
||||
ctx.Data["LabelTemplateFiles"] = repo_module.LabelTemplateFiles
|
||||
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -40,13 +40,13 @@ func Applications(ctx *context.Context) {
|
||||
OwnerID: ctx.Org.Organization.ID,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetOAuth2ApplicationsByUserID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Applications"] = apps
|
||||
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ func Packages(ctx *context.Context) {
|
||||
ctx.Data["PageIsSettingsPackages"] = true
|
||||
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func PackagesRuleAdd(ctx *context.Context) {
|
||||
ctx.Data["PageIsSettingsPackages"] = true
|
||||
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ func PackagesRuleEdit(ctx *context.Context) {
|
||||
ctx.Data["PageIsSettingsPackages"] = true
|
||||
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ func PackagesRulePreview(ctx *context.Context) {
|
||||
ctx.Data["PageIsSettingsPackages"] = true
|
||||
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+23
-31
@@ -49,7 +49,7 @@ const (
|
||||
// Teams render teams list page
|
||||
func Teams(ctx *context.Context) {
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
org := ctx.Org.Organization
|
||||
@@ -90,13 +90,13 @@ func Teams(ctx *context.Context) {
|
||||
|
||||
teams, count, err := searchTeams()
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchTeam", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
for _, t := range teams {
|
||||
if err := t.LoadMembers(ctx); err != nil {
|
||||
ctx.ServerError("GetMembers", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -180,7 +180,7 @@ func TeamsAction(ctx *context.Context) {
|
||||
} else if org_model.IsErrUserEmailAlreadyAdded(err) {
|
||||
ctx.Flash.Error(ctx.Tr("org.teams.add_duplicate_users"))
|
||||
} else {
|
||||
ctx.ServerError("CreateTeamInvite", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -189,7 +189,7 @@ func TeamsAction(ctx *context.Context) {
|
||||
}
|
||||
ctx.Redirect(ctx.Org.OrgLink + "/teams/" + url.PathEscape(ctx.Org.Team.LowerName))
|
||||
} else {
|
||||
ctx.ServerError("GetUserByName", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -221,7 +221,7 @@ func TeamsAction(ctx *context.Context) {
|
||||
|
||||
if err := org_model.RemoveInviteByID(ctx, iid, ctx.Org.Team.ID); err != nil {
|
||||
log.Error("Action(%s): %v", ctx.PathParam("action"), err)
|
||||
ctx.ServerError("RemoveInviteByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ func TeamsAction(ctx *context.Context) {
|
||||
|
||||
func checkIsOrgMemberAndRedirect(ctx *context.Context, defaultRedirect string) {
|
||||
if isOrgMember, err := org_model.IsOrganizationMember(ctx, ctx.Org.Organization.ID, ctx.Doer.ID); err != nil {
|
||||
ctx.ServerError("IsOrganizationMember", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
} else if !isOrgMember && !ctx.Doer.IsAdmin {
|
||||
if ctx.Org.Organization.Visibility.IsPrivate() {
|
||||
@@ -287,7 +287,7 @@ func TeamsRepoAction(ctx *context.Context) {
|
||||
ctx.Redirect(ctx.Org.OrgLink + "/teams/" + url.PathEscape(ctx.Org.Team.LowerName) + "/repositories")
|
||||
return
|
||||
}
|
||||
ctx.ServerError("GetRepositoryByName", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
err = repo_service.TeamAddRepository(ctx, ctx.Org.Team, repo)
|
||||
@@ -301,7 +301,7 @@ func TeamsRepoAction(ctx *context.Context) {
|
||||
|
||||
if err != nil {
|
||||
log.Error("Action(%s): '%s' %v", ctx.PathParam("action"), ctx.Org.Team.Name, err)
|
||||
ctx.ServerError("TeamsRepoAction", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ func TeamsRepoAction(ctx *context.Context) {
|
||||
// NewTeam render create new team page
|
||||
func NewTeam(ctx *context.Context) {
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Title"] = ctx.Org.Organization.FullName
|
||||
@@ -381,7 +381,7 @@ func NewTeamPost(ctx *context.Context) {
|
||||
case org_model.IsErrTeamAlreadyExist(err):
|
||||
ctx.RenderWithErrDeprecated(ctx.Tr("form.team_name_been_taken"), tplTeamNew, &form)
|
||||
default:
|
||||
ctx.ServerError("NewTeam", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -392,7 +392,7 @@ func NewTeamPost(ctx *context.Context) {
|
||||
// TeamMembers render team members page
|
||||
func TeamMembers(ctx *context.Context) {
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -401,14 +401,14 @@ func TeamMembers(ctx *context.Context) {
|
||||
ctx.Data["PageIsOrgTeamMembers"] = true
|
||||
|
||||
if err := ctx.Org.Team.LoadMembers(ctx); err != nil {
|
||||
ctx.ServerError("GetMembers", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Units"] = unit_model.Units
|
||||
|
||||
invites, err := org_model.GetInvitesByTeamID(ctx, ctx.Org.Team.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetInvitesByTeamID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Invites"] = invites
|
||||
@@ -420,7 +420,7 @@ func TeamMembers(ctx *context.Context) {
|
||||
// TeamRepositories show the repositories of team
|
||||
func TeamRepositories(ctx *context.Context) {
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -432,7 +432,7 @@ func TeamRepositories(ctx *context.Context) {
|
||||
TeamID: ctx.Org.Team.ID,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetTeamRepositories", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Units"] = unit_model.Units
|
||||
@@ -449,7 +449,7 @@ func SearchTeam(ctx *context.Context) {
|
||||
|
||||
shouldSeeAll, err := context.UserShouldSeeAllOrgTeams(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("UserShouldSeeAllOrgTeams", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -494,13 +494,13 @@ func SearchTeam(ctx *context.Context) {
|
||||
// EditTeam render team edit page
|
||||
func EditTeam(ctx *context.Context) {
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Title"] = ctx.Org.Organization.FullName
|
||||
ctx.Data["PageIsOrgTeams"] = true
|
||||
if err := ctx.Org.Team.LoadUnits(ctx); err != nil {
|
||||
ctx.ServerError("LoadUnits", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Team"] = ctx.Org.Team
|
||||
@@ -560,7 +560,7 @@ func EditTeamPost(ctx *context.Context) {
|
||||
case org_model.IsErrTeamAlreadyExist(err):
|
||||
ctx.RenderWithErrDeprecated(ctx.Tr("form.team_name_been_taken"), tplTeamNew, &form)
|
||||
default:
|
||||
ctx.ServerError("UpdateTeam", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -584,11 +584,7 @@ func TeamInvite(ctx *context.Context) {
|
||||
// TODO: to quickly debug the UI, can uncomment this (don't worry, it won't pass CI lint)
|
||||
// invite, org, team, inviter, err = &org_model.TeamInvite{}, &org_model.Organization{}, &org_model.Team{}, ctx.Doer, nil
|
||||
if err != nil {
|
||||
if org_model.IsErrTeamInviteNotFound(err) {
|
||||
ctx.NotFound(err)
|
||||
} else {
|
||||
ctx.ServerError("getTeamInviteFromContext", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -605,16 +601,12 @@ func TeamInvite(ctx *context.Context) {
|
||||
func TeamInvitePost(ctx *context.Context) {
|
||||
invite, org, team, _, err := getTeamInviteFromContext(ctx)
|
||||
if err != nil {
|
||||
if org_model.IsErrTeamInviteNotFound(err) {
|
||||
ctx.NotFound(err)
|
||||
} else {
|
||||
ctx.ServerError("getTeamInviteFromContext", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := org_service.AddTeamMember(ctx, team, ctx.Doer); err != nil {
|
||||
ctx.ServerError("AddTeamMember", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -32,11 +32,11 @@ func parseOrgTimes(ctx *context.Context) (unixFrom, unixTo int64) {
|
||||
|
||||
timeFrom, err := time.Parse("2006-01-02", rangeFrom)
|
||||
if err != nil {
|
||||
ctx.ServerError("time.Parse", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
timeTo, err := time.Parse("2006-01-02", rangeTo)
|
||||
if err != nil {
|
||||
ctx.ServerError("time.Parse", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
unixFrom = timeFrom.Unix()
|
||||
unixTo = timeTo.Add(1440*time.Minute - 1*time.Second).Unix() // humans expect that we include the ending day too
|
||||
@@ -68,12 +68,12 @@ func Worktime(ctx *context.Context) {
|
||||
ctx.Data["WorktimeByRepos"] = true
|
||||
}
|
||||
if err != nil {
|
||||
ctx.ServerError("GetWorktime", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := shared_user.RenderUserOrgHeader(ctx); err != nil {
|
||||
ctx.ServerError("RenderUserOrgHeader", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -67,18 +67,18 @@ func (w WorkflowInfo) DisplayName() string {
|
||||
// MustEnableActions check if actions are enabled in settings
|
||||
func MustEnableActions(ctx *context.Context) {
|
||||
if !setting.Actions.Enabled {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
if unit.TypeActions.UnitGlobalDisabled() {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.Repo.Repository != nil {
|
||||
if !ctx.Repo.Permission.CanRead(unit.TypeActions) {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -91,10 +91,10 @@ func List(ctx *context.Context) {
|
||||
commit, err := ctx.Repo.GitRepo.GetBranchCommit(ctx, ctx.Repo.Repository.DefaultBranch)
|
||||
if errors.Is(err, util.ErrNotExist) {
|
||||
ctx.Data["NotFoundPrompt"] = ctx.Tr("repo.branch.default_branch_not_exist", ctx.Repo.Repository.DefaultBranch)
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
} else if err != nil {
|
||||
ctx.ServerError("GetBranchCommit", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ func prepareOtherWorkflows(ctx *context.Context, workflows []WorkflowInfo, scope
|
||||
// "Other workflows" lists repo-level orphans only: GetRepoRunWorkflowIDs excludes scoped runs.
|
||||
ids, err := actions_model.GetRepoRunWorkflowIDs(ctx, ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRepoRunWorkflowIDs", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
other = container.FilterSlice(ids, func(id string) (string, bool) {
|
||||
@@ -174,7 +174,7 @@ func prepareOtherWorkflows(ctx *context.Context, workflows []WorkflowInfo, scope
|
||||
func WorkflowDispatchInputs(ctx *context.Context) {
|
||||
ref := ctx.FormString("ref")
|
||||
if ref == "" {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
// get target commit of run from specified ref
|
||||
@@ -186,11 +186,11 @@ func WorkflowDispatchInputs(ctx *context.Context) {
|
||||
} else if refName.IsBranch() {
|
||||
commit, err = ctx.Repo.GitRepo.GetBranchCommit(ctx, refName.BranchName())
|
||||
} else {
|
||||
ctx.ServerError("UnsupportedRefType", nil)
|
||||
ctx.ServerErrorAuto(errors.New("UnsupportedRefType"))
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
ctx.ServerError("GetTagCommit/GetBranchCommit", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
workflows, curWorkflowID := prepareWorkflowTemplate(ctx, commit)
|
||||
@@ -209,7 +209,7 @@ func prepareWorkflowTemplate(ctx *context.Context, commit *git.Commit) (workflow
|
||||
|
||||
_, entries, err := actions.ListWorkflows(ctx, ctx.Repo.GitRepo, commit)
|
||||
if err != nil {
|
||||
ctx.ServerError("ListWorkflows", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, ""
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ func prepareWorkflowTemplate(ctx *context.Context, commit *git.Commit) (workflow
|
||||
workflow := WorkflowInfo{EntryName: entry.Name()}
|
||||
content, err := actions.GetContentFromEntry(ctx, ctx.Repo.GitRepo, entry)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetContentFromEntry", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, ""
|
||||
}
|
||||
wf, err := jobparser.ReadWorkflow(content)
|
||||
@@ -307,7 +307,7 @@ func prepareScopedWorkflows(ctx *context.Context, curWorkflowID string, curWorkf
|
||||
repo := ctx.Repo.Repository
|
||||
sources, err := actions_model.GetEffectiveScopedWorkflowSources(ctx, repo.OwnerID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetEffectiveScopedWorkflowSources", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return scopedNames
|
||||
}
|
||||
if len(sources) == 0 {
|
||||
@@ -465,7 +465,7 @@ func prepareWorkflowDispatchTemplate(ctx *context.Context, workflowInfos []Workf
|
||||
}
|
||||
branches, err := git_model.FindBranchNames(ctx, branchOpts)
|
||||
if err != nil {
|
||||
ctx.ServerError("FindBranchNames", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
// always put default branch on the top
|
||||
@@ -475,7 +475,7 @@ func prepareWorkflowDispatchTemplate(ctx *context.Context, workflowInfos []Workf
|
||||
|
||||
tags, err := repo_model.GetTagNamesByRepoID(ctx, ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetTagNamesByRepoID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Tags"] = tags
|
||||
@@ -508,7 +508,7 @@ func (data *actionRunListData) prepareFullPageRuns(ctx *context.Context, otherWo
|
||||
|
||||
runs, total, err := db.FindAndCount[actions_model.ActionRun](ctx, opts)
|
||||
if err != nil {
|
||||
ctx.ServerError("FindAndCount", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return false
|
||||
}
|
||||
data.pager = context.NewPagerBuilder(ctx).TotalCount(total).PerPageLimit(opts.PageSize).CurPage(opts.Page).Build()
|
||||
@@ -546,7 +546,7 @@ func (data *actionRunListData) processActionRuns(ctx *context.Context) bool {
|
||||
WithAvailable: true,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("FindRunners", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -555,7 +555,7 @@ func (data *actionRunListData) processActionRuns(ctx *context.Context) bool {
|
||||
})
|
||||
jobsByRun, err := actions_model.GetLatestAttemptJobsByRuns(ctx, activeRuns)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetLatestAttemptJobsByRuns", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -647,7 +647,7 @@ func prepareWorkflowList(ctx *context.Context, curWorkflowID string) *actionRunL
|
||||
func (data *actionRunListData) preparePartialRefreshRuns(ctx *context.Context) bool {
|
||||
runs, err := actions_model.GetRunsByRepoAndID(ctx, ctx.Repo.Repository.ID, data.refreshRunIDs)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRunsByRepoAndID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return false
|
||||
}
|
||||
runsMap := make(map[int64]*actions_model.ActionRun, len(runs))
|
||||
@@ -668,7 +668,7 @@ func (data *actionRunListData) prepareCommon(ctx *context.Context, workflows []W
|
||||
}
|
||||
|
||||
if err := actions_model.RunList(data.ActionRuns).LoadTriggerUser(ctx); err != nil {
|
||||
ctx.ServerError("LoadTriggerUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return false
|
||||
}
|
||||
if err := loadIsRefDeleted(ctx, ctx.Repo.Repository.ID, data.ActionRuns); err != nil {
|
||||
@@ -698,14 +698,14 @@ func (data *actionRunListData) prepareFullPageTemplate(ctx *context.Context) boo
|
||||
// fill template data
|
||||
actors, err := actions_model.GetActors(ctx, ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetActors", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return false
|
||||
}
|
||||
ctx.Data["Actors"] = shared_user.MakeSelfOnTop(ctx.Doer, actors)
|
||||
|
||||
runBranches, err := actions_model.GetRunBranches(ctx, ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRunBranches", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return false
|
||||
}
|
||||
ctx.Data["RunBranches"] = runBranches
|
||||
|
||||
@@ -31,7 +31,7 @@ func GetWorkflowBadge(ctx *context.Context) {
|
||||
branchRef := git.RefNameFromBranch(branch)
|
||||
b, err := getWorkflowBadge(ctx, workflowFile, branchRef.String(), event)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetWorkflowBadge", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@ func prepareActionsSidebar(ctx *context.Context) {
|
||||
commit, err := ctx.Repo.GitRepo.GetBranchCommit(ctx, ctx.Repo.Repository.DefaultBranch)
|
||||
if errors.Is(err, util.ErrNotExist) {
|
||||
ctx.Data["NotFoundPrompt"] = ctx.Tr("repo.branch.default_branch_not_exist", ctx.Repo.Repository.DefaultBranch)
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
} else if err != nil {
|
||||
ctx.ServerError("GetBranchCommit", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -66,10 +66,8 @@ func getCurrentRunByPathParam(ctx *context_module.Context) (run *actions_model.A
|
||||
} else {
|
||||
run, err = actions_model.GetRunByRepoAndID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("run"))
|
||||
}
|
||||
if errors.Is(err, util.ErrNotExist) {
|
||||
ctx.NotFound(nil)
|
||||
} else if err != nil {
|
||||
ctx.ServerError("GetRun:"+ctx.PathParam("run"), err)
|
||||
if err != nil {
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return run
|
||||
}
|
||||
@@ -90,7 +88,7 @@ func resolveCurrentRunForView(ctx *context_module.Context) *actions_model.Action
|
||||
|
||||
runNum := ctx.PathParamInt64("run")
|
||||
if runNum <= 0 {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -113,7 +111,7 @@ func resolveCurrentRunForView(ctx *context_module.Context) *actions_model.Action
|
||||
return runByID
|
||||
}
|
||||
if !errors.Is(err, util.ErrNotExist) {
|
||||
ctx.ServerError("GetRun:"+ctx.PathParam("run"), err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -124,16 +122,16 @@ func resolveCurrentRunForView(ctx *context_module.Context) *actions_model.Action
|
||||
return nil
|
||||
}
|
||||
if !errors.Is(err, util.ErrNotExist) {
|
||||
ctx.ServerError("GetRunByRepoAndIndex", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return nil
|
||||
}
|
||||
|
||||
jobNum := ctx.PathParamInt64("job")
|
||||
if jobNum < 0 {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -149,12 +147,12 @@ func resolveCurrentRunForView(ctx *context_module.Context) *actions_model.Action
|
||||
// Probe the repo-scoped job ID first and only accept it when the job exists and belongs to the same runNum.
|
||||
job, err := actions_model.GetRunJobByRepoAndID(ctx, ctx.Repo.Repository.ID, jobNum)
|
||||
if err != nil && !errors.Is(err, util.ErrNotExist) {
|
||||
ctx.ServerError("GetRunJobByRepoAndID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
if job != nil {
|
||||
if err := job.LoadRun(ctx); err != nil {
|
||||
ctx.ServerError("LoadRun", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
if job.Run.ID == runNum {
|
||||
@@ -167,13 +165,13 @@ func resolveCurrentRunForView(ctx *context_module.Context) *actions_model.Action
|
||||
{
|
||||
run, err := actions_model.GetRunByRepoAndIndex(ctx, ctx.Repo.Repository.ID, runNum)
|
||||
if err != nil && !errors.Is(err, util.ErrNotExist) {
|
||||
ctx.ServerError("GetRunByRepoAndIndex", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
if run != nil {
|
||||
jobs, err := actions_model.GetLatestAttemptJobsByRepoAndRunID(ctx, run.RepoID, run.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRunJobsByRunID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
if jobNum < int64(len(jobs)) {
|
||||
@@ -184,7 +182,7 @@ func resolveCurrentRunForView(ctx *context_module.Context) *actions_model.Action
|
||||
}
|
||||
|
||||
if runByID == nil && runByIndex == nil {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -252,12 +250,12 @@ func ViewWorkflowFile(ctx *context_module.Context) {
|
||||
|
||||
commit, err := ctx.Repo.GitRepo.GetCommit(ctx, run.CommitSHA)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetCommit", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
rpath, entries, err := actions.ListWorkflows(ctx, ctx.Repo.GitRepo, commit)
|
||||
if err != nil {
|
||||
ctx.ServerError("ListWorkflows", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
for _, entry := range entries {
|
||||
@@ -266,7 +264,7 @@ func ViewWorkflowFile(ctx *context_module.Context) {
|
||||
return
|
||||
}
|
||||
}
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
}
|
||||
|
||||
type LogCursor struct {
|
||||
@@ -544,7 +542,7 @@ func ViewPost(ctx *context_module.Context) {
|
||||
return
|
||||
}
|
||||
if err := run.LoadAttributes(ctx); err != nil {
|
||||
ctx.ServerError("run.LoadAttributes", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -633,11 +631,11 @@ func fillViewRunResponseSummary(ctx *context_module.Context, resp *ViewResponse,
|
||||
|
||||
attempts, err := actions_model.ListRunAttemptsByRunID(ctx, run.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("ListRunAttemptsByRunID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if err := attempts.LoadTriggerUser(ctx); err != nil {
|
||||
ctx.ServerError("LoadTriggerUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
for _, runAttempt := range attempts {
|
||||
@@ -677,7 +675,7 @@ func fillViewRunResponseSummary(ctx *context_module.Context, resp *ViewResponse,
|
||||
// Scoping server-side avoids rendering every job's markdown on each 1s poll.
|
||||
summaries, err := actions_model.ListActionRunJobSummaries(ctx, ctx.Repo.Repository.ID, run.ID, runAttemptID, ctx.PathParamInt64("job"))
|
||||
if err != nil {
|
||||
ctx.ServerError("ListActionRunJobSummaries", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if len(summaries) > 0 {
|
||||
@@ -702,7 +700,7 @@ func fillViewRunResponseSummary(ctx *context_module.Context, resp *ViewResponse,
|
||||
|
||||
arts, err := actions_model.ListUploadedArtifactsMetaByRunAttempt(ctx, ctx.Repo.Repository.ID, run.ID, runAttemptID)
|
||||
if err != nil {
|
||||
ctx.ServerError("ListUploadedArtifactsMetaByRunAttempt", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
resp.Artifacts = make([]*ArtifactsViewItem, 0, len(arts))
|
||||
@@ -724,7 +722,7 @@ func fillViewRunResponseCurrentJob(ctx *context_module.Context, resp *ViewRespon
|
||||
current, hasPathParam := findCurrentJobByPathParam(ctx, jobs)
|
||||
if current == nil {
|
||||
if hasPathParam {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -734,12 +732,12 @@ func fillViewRunResponseCurrentJob(ctx *context_module.Context, resp *ViewRespon
|
||||
var err error
|
||||
task, err = actions_model.GetTaskByID(ctx, effectiveTaskID)
|
||||
if err != nil {
|
||||
ctx.ServerError("actions_model.GetTaskByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
task.Job = current
|
||||
if err := task.LoadAttributes(ctx); err != nil {
|
||||
ctx.ServerError("task.LoadAttributes", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -756,7 +754,7 @@ func fillViewRunResponseCurrentJob(ctx *context_module.Context, resp *ViewRespon
|
||||
if task != nil {
|
||||
steps, logs, err := convertToViewModel(ctx, ctx.Locale, req.LogCursors, task)
|
||||
if err != nil {
|
||||
ctx.ServerError("convertToViewModel", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
resp.State.CurrentJob.Steps = append(resp.State.CurrentJob.Steps, steps...)
|
||||
@@ -929,7 +927,7 @@ func checkRunRerunAllowed(ctx *context_module.Context, run *actions_model.Action
|
||||
if run.IsScopedRun {
|
||||
optedOut, err := actions_model.IsScopedWorkflowOptedOut(ctx, cfg, ctx.Repo.Repository.OwnerID, run.WorkflowRepoID, run.WorkflowID)
|
||||
if err != nil {
|
||||
ctx.ServerError("IsScopedWorkflowOptedOut", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return false
|
||||
}
|
||||
disabled = optedOut
|
||||
@@ -943,7 +941,7 @@ func checkRunRerunAllowed(ctx *context_module.Context, run *actions_model.Action
|
||||
|
||||
func checkLatestAttempt(ctx *context_module.Context, run *actions_model.ActionRun, attempt *actions_model.ActionRunAttempt) bool {
|
||||
if attempt != nil && run.LatestAttemptID != attempt.ID {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return false
|
||||
}
|
||||
return true
|
||||
@@ -969,7 +967,7 @@ func Rerun(ctx *context_module.Context) {
|
||||
|
||||
currentJob, hasPathParam := findCurrentJobByPathParam(ctx, jobs)
|
||||
if hasPathParam && currentJob == nil {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1024,7 +1022,7 @@ func handleWorkflowRerunError(ctx *context_module.Context, err error) {
|
||||
ctx.JSON(http.StatusBadRequest, map[string]any{"message": err.Error()})
|
||||
return
|
||||
}
|
||||
ctx.ServerError("RerunWorkflowRunJobs", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
|
||||
func Logs(ctx *context_module.Context) {
|
||||
@@ -1035,7 +1033,7 @@ func Logs(ctx *context_module.Context) {
|
||||
jobID := ctx.PathParamInt64("job")
|
||||
|
||||
if err := common.DownloadActionsRunJobLogsWithID(ctx.Base, ctx.Repo.Repository, run.ID, jobID); err != nil {
|
||||
ctx.ServerError("DownloadActionsRunJobLogsWithID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1049,7 +1047,7 @@ func Cancel(ctx *context_module.Context) {
|
||||
}
|
||||
|
||||
if _, err := actions_service.CancelRun(ctx, run, jobs); err != nil {
|
||||
ctx.ServerError("CancelRun", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.JSONOK()
|
||||
@@ -1061,7 +1059,7 @@ func Approve(ctx *context_module.Context) {
|
||||
return
|
||||
}
|
||||
if _, err := actions_service.ApproveRuns(ctx, ctx.Repo.Repository, ctx.Doer, []int64{run.ID}); err != nil {
|
||||
ctx.ServerError("ApproveRuns", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1080,7 +1078,7 @@ func Delete(ctx *context_module.Context) {
|
||||
}
|
||||
|
||||
if err := actions_service.DeleteRun(ctx, run); err != nil {
|
||||
ctx.ServerError("DeleteRun", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1109,7 +1107,7 @@ func getCurrentRunJobsByPathParam(ctx *context_module.Context) (*actions_model.A
|
||||
jobID := ctx.PathParamInt64("job")
|
||||
selectedJob, err = actions_model.GetRunJobByRunAndID(ctx, run.ID, jobID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRunJobByRunAndID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, nil, nil
|
||||
}
|
||||
}
|
||||
@@ -1124,21 +1122,21 @@ func getCurrentRunJobsByPathParam(ctx *context_module.Context) (*actions_model.A
|
||||
// Explicit attempt number in the URL — user is viewing a historical attempt.
|
||||
attempt, err = actions_model.GetRunAttemptByRunIDAndAttemptNum(ctx, run.ID, attemptNum)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRunAttemptByRunIDAndAttemptNum", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, nil, nil
|
||||
}
|
||||
case selectedJob != nil && selectedJob.RunAttemptID > 0:
|
||||
// No explicit attempt in the URL, but the requested job belongs to a known attempt — resolve via the job.
|
||||
attempt, err = actions_model.GetRunAttemptByRepoAndID(ctx, selectedJob.RepoID, selectedJob.RunAttemptID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRunAttemptByRepoAndID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, nil, nil
|
||||
}
|
||||
default:
|
||||
// No attempt context at all — show the latest attempt (nil for legacy runs).
|
||||
attempt, _, err = run.GetLatestAttempt(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetLatestAttempt", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, nil, nil
|
||||
}
|
||||
}
|
||||
@@ -1151,7 +1149,7 @@ func getCurrentRunJobsByPathParam(ctx *context_module.Context) (*actions_model.A
|
||||
}
|
||||
jobs, err := actions_model.GetRunJobsByRunAndAttemptID(ctx, run.ID, resolvedAttemptID)
|
||||
if err != nil {
|
||||
ctx.ServerError("get current jobs", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, nil, nil
|
||||
}
|
||||
jobs.SortMatrixGroupsByName()
|
||||
@@ -1187,12 +1185,12 @@ func ArtifactsDeleteView(ctx *context_module.Context) {
|
||||
}
|
||||
resolvedAttemptID, err := resolveArtifactAttemptIDFromQuery(ctx, run)
|
||||
if err != nil {
|
||||
ctx.ServerError("resolveArtifactAttemptIDFromQuery", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
artifactName := ctx.PathParam("artifact_name")
|
||||
if err := actions_model.SetArtifactNeedDeleteByRunAttempt(ctx, run.ID, resolvedAttemptID, artifactName); err != nil {
|
||||
ctx.ServerError("SetArtifactNeedDeleteByRunAttempt", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK, struct{}{})
|
||||
@@ -1205,13 +1203,13 @@ func ArtifactsDownloadView(ctx *context_module.Context) {
|
||||
}
|
||||
resolvedAttemptID, err := resolveArtifactAttemptIDFromQuery(ctx, run)
|
||||
if err != nil {
|
||||
ctx.ServerError("resolveArtifactAttemptIDFromQuery", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
artifactName := ctx.PathParam("artifact_name")
|
||||
artifacts, err := actions_model.GetArtifactsByRunAttemptAndName(ctx, run.ID, resolvedAttemptID, artifactName)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetArtifactsByRunAttemptAndName", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if len(artifacts) == 0 {
|
||||
@@ -1233,7 +1231,7 @@ func ArtifactsDownloadView(ctx *context_module.Context) {
|
||||
if len(artifacts) == 1 && actions_service.IsArtifactV4(artifacts[0]) {
|
||||
err := actions_service.DownloadArtifactV4(ctx.Base, artifacts[0])
|
||||
if err != nil {
|
||||
ctx.ServerError("DownloadArtifactV4", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
return
|
||||
@@ -1275,7 +1273,7 @@ func ArtifactsDownloadView(ctx *context_module.Context) {
|
||||
for _, art := range artifacts {
|
||||
err := writeArtifactToZip(art)
|
||||
if err != nil {
|
||||
ctx.ServerError("writeArtifactToZip", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -1287,12 +1285,12 @@ func ApproveAllChecks(ctx *context_module.Context) {
|
||||
|
||||
commitStatuses, err := git_model.GetLatestCommitStatus(ctx, repo.ID, commitID, db.ListOptionsAll)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetLatestCommitStatus", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
runs, err := actions_service.GetRunsFromCommitStatuses(ctx, repo.ID, commitStatuses)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRunsFromCommitStatuses", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1309,7 +1307,7 @@ func ApproveAllChecks(ctx *context_module.Context) {
|
||||
}
|
||||
|
||||
if _, err := actions_service.ApproveRuns(ctx, repo, ctx.Doer, runIDs); err != nil {
|
||||
ctx.ServerError("ApproveRuns", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1341,7 +1339,7 @@ func disableOrEnableWorkflowFile(ctx *context_module.Context, isEnable bool) {
|
||||
// a required scoped workflow can never be opted out
|
||||
required, err := actions_model.IsScopedWorkflowRequired(ctx, ctx.Repo.Repository.OwnerID, scopedRepoID, workflow)
|
||||
if err != nil {
|
||||
ctx.ServerError("IsScopedWorkflowRequired", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if required {
|
||||
@@ -1359,7 +1357,7 @@ func disableOrEnableWorkflowFile(ctx *context_module.Context, isEnable bool) {
|
||||
}
|
||||
|
||||
if err := repo_model.UpdateRepoUnitConfig(ctx, cfgUnit); err != nil {
|
||||
ctx.ServerError("UpdateRepoUnit", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
actions_service.RecordWorkflowToggle(ctx, ctx.Repo.Repository, workflow, isEnable)
|
||||
@@ -1381,13 +1379,13 @@ func Run(ctx *context_module.Context) {
|
||||
|
||||
workflowID := ctx.FormString("workflow")
|
||||
if len(workflowID) == 0 {
|
||||
ctx.ServerError("workflow", nil)
|
||||
ctx.ServerErrorAuto(errors.New("workflow"))
|
||||
return
|
||||
}
|
||||
|
||||
ref := ctx.FormString("ref")
|
||||
if len(ref) == 0 {
|
||||
ctx.ServerError("ref", nil)
|
||||
ctx.ServerErrorAuto(errors.New("ref"))
|
||||
return
|
||||
}
|
||||
sourceRepoID := ctx.FormInt64("scoped_workflow_source_repo_id")
|
||||
@@ -1418,35 +1416,35 @@ func Run(ctx *context_module.Context) {
|
||||
func viewScopedWorkflowFile(ctx *context_module.Context, run *actions_model.ActionRun) {
|
||||
sourceRepo, err := repo_model.GetRepositoryByID(ctx, run.WorkflowRepoID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRepositoryByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
perm, err := access_model.GetDoerRepoPermission(ctx, sourceRepo, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetUserRepoPermission", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if !perm.CanRead(unit.TypeCode) {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
sourceGitRepo, err := git.OpenRepository(ctx, sourceRepo)
|
||||
if err != nil {
|
||||
ctx.ServerError("OpenRepository", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
defer sourceGitRepo.Close()
|
||||
|
||||
commit, err := sourceGitRepo.GetCommit(ctx, run.WorkflowCommitSHA)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetCommit", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
rpath, entries, err := actions.ListScopedWorkflows(ctx, sourceGitRepo, commit)
|
||||
if err != nil {
|
||||
ctx.ServerError("ListScopedWorkflows", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
for _, entry := range entries {
|
||||
@@ -1455,7 +1453,7 @@ func viewScopedWorkflowFile(ctx *context_module.Context, run *actions_model.Acti
|
||||
return
|
||||
}
|
||||
}
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
}
|
||||
|
||||
// canViewScopedWorkflowFile reports whether the viewer may follow the "Workflow file" link of a scoped run.
|
||||
|
||||
@@ -340,7 +340,7 @@ func ServeArtifactPreviewContent(ctx *context_module.Base, filePath string, read
|
||||
|
||||
func ArtifactsPreviewView(ctx *context_module.Context) {
|
||||
if setting.Actions.ArtifactPreviewMaxSize == 0 {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
artifacts, err := loadUploadedArtifactsByID(ctx, ctx.PathParamInt64("artifact_id"))
|
||||
@@ -348,13 +348,13 @@ func ArtifactsPreviewView(ctx *context_module.Context) {
|
||||
err = util.ErrNotExist
|
||||
}
|
||||
if err != nil {
|
||||
ctx.ServerError("loadUploadedArtifactsByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
artifact := artifacts[0]
|
||||
run, err := actions_model.GetRunByRepoAndID(ctx, artifact.RepoID, artifact.RunID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRunByRepoAndID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
run.Repo = ctx.Repo.Repository
|
||||
@@ -369,7 +369,7 @@ func ArtifactsPreviewView(ctx *context_module.Context) {
|
||||
if artifact.RunAttemptID > 0 {
|
||||
attempt, err := actions_model.GetRunAttemptByRepoAndID(ctx, artifact.RepoID, artifact.RunAttemptID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRunAttemptByRepoAndID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
data.RunAttempt = attempt.Attempt
|
||||
@@ -380,7 +380,7 @@ func ArtifactsPreviewView(ctx *context_module.Context) {
|
||||
var list artifactPreviewList
|
||||
if !data.PreviewTooLarge {
|
||||
if list, err = listPreview(artifacts); err != nil {
|
||||
ctx.ServerError("listPreview", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func Activity(ctx *context.Context) {
|
||||
branchExist, _ := git_model.IsBranchExist(ctx, ctx.Repo.Repository.ID, ctx.Repo.Repository.DefaultBranch)
|
||||
if !branchExist {
|
||||
ctx.Data["NotFoundPrompt"] = ctx.Tr("repo.branch.default_branch_not_exist", ctx.Repo.Repository.DefaultBranch)
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -68,12 +68,12 @@ func Activity(ctx *context.Context) {
|
||||
canReadCode,
|
||||
)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetActivityStats", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.PageData["repoActivityTopAuthors"], err = activities_model.GetActivityStatsTopAuthors(ctx, ctx.Repo.Repository, timeFrom, 10); err != nil {
|
||||
ctx.ServerError("GetActivityStatsTopAuthors", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ func ActivityAuthors(ctx *context.Context) {
|
||||
|
||||
authors, err := activities_model.GetActivityStatsTopAuthors(ctx, ctx.Repo.Repository, timeFrom, 10)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetActivityStatsTopAuthors", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ func uploadAttachment(ctx *context.Context, repoID int64, uploadFunc attachment.
|
||||
|
||||
file, header, err := ctx.Req.FormFile("file")
|
||||
if err != nil {
|
||||
ctx.ServerError("FormFile", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
@@ -67,7 +67,7 @@ func uploadAttachment(ctx *context.Context, repoID int64, uploadFunc attachment.
|
||||
ctx.HTTPError(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
ctx.ServerError("uploadAttachment(uploadFunc)", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ func DeletePendingAttachment(ctx *context.Context) {
|
||||
file := ctx.FormString("file")
|
||||
attach, err := repo_model.GetAttachmentByUUID(ctx, file)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetAttachmentByUUID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ func DeletePendingAttachment(ctx *context.Context) {
|
||||
|
||||
err = repo_model.DeleteAttachment(ctx, attach, true)
|
||||
if err != nil {
|
||||
ctx.ServerError("DeleteAttachment", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK, map[string]string{
|
||||
@@ -112,14 +112,14 @@ func ServeAttachment(ctx *context.Context, uuid string) {
|
||||
if repo_model.IsErrAttachmentNotExist(err) {
|
||||
ctx.HTTPError(http.StatusNotFound)
|
||||
} else {
|
||||
ctx.ServerError("GetAttachmentByUUID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
unitType, repoID, err := repo_service.GetAttachmentLinkedTypeAndRepoID(ctx, attach)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetAttachmentLinkedTypeAndRepoID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if repoID == 0 {
|
||||
@@ -143,12 +143,12 @@ func ServeAttachment(ctx *context.Context, uuid string) {
|
||||
if repo == nil {
|
||||
repo, err = repo_model.GetRepositoryByID(ctx, repoID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRepositoryByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
perm, err = access_model.GetDoerRepoPermission(ctx, repo, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDoerRepoPermission", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@@ -167,7 +167,7 @@ func ServeAttachment(ctx *context.Context, uuid string) {
|
||||
if unitType == unit.TypeReleases && attach.ReleaseID != 0 && !perm.CanWrite(unit.TypeReleases) {
|
||||
rel, err := repo_model.GetReleaseByID(ctx, attach.ReleaseID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetReleaseByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if rel.IsDraft {
|
||||
@@ -185,7 +185,7 @@ func ServeAttachment(ctx *context.Context, uuid string) {
|
||||
}
|
||||
|
||||
if err := attach.IncreaseDownloadCount(ctx); err != nil {
|
||||
ctx.ServerError("IncreaseDownloadCount", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ func ServeAttachment(ctx *context.Context, uuid string) {
|
||||
// If we have matched and access to release or issue
|
||||
fr, err := storage.Attachments.Open(attach.RelativePath())
|
||||
if err != nil {
|
||||
ctx.ServerError("Open", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
defer fr.Close()
|
||||
|
||||
+10
-10
@@ -46,12 +46,16 @@ func RefBlame(ctx *context.Context) {
|
||||
|
||||
// Get current entry user currently looking at.
|
||||
if ctx.Repo.TreePath == "" {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(ctx, ctx.Repo.GitRepo, ctx.Repo.TreePath)
|
||||
if err != nil {
|
||||
HandleGitError(ctx, "Repo.Commit.GetTreeEntryByPath", err)
|
||||
HandleGitError(ctx, err)
|
||||
return
|
||||
}
|
||||
if entry.IsDir() { // a directory has no blame, show its tree instead
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL() + "/" + util.PathEscapeSegments(ctx.Repo.TreePath))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -74,14 +78,14 @@ func RefBlame(ctx *context.Context) {
|
||||
|
||||
_, ctx.Data["NumLines"], err = blob.GetBlobLineCount(ctx, nil)
|
||||
if err != nil {
|
||||
ctx.NotFound(err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
bypassBlameIgnore, _ := strconv.ParseBool(ctx.FormString("bypass-blame-ignore"))
|
||||
result, err := performBlame(ctx, bypassBlameIgnore)
|
||||
if err != nil {
|
||||
ctx.NotFound(err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -199,11 +203,7 @@ func processBlameParts(ctx *context.Context, blameParts []*git.BlamePart) map[st
|
||||
if !ok {
|
||||
commit, err = ctx.Repo.GitRepo.GetCommit(ctx, sha)
|
||||
if err != nil {
|
||||
if git.IsErrNotExist(err) {
|
||||
ctx.NotFound(err)
|
||||
} else {
|
||||
ctx.ServerError("Repo.GitRepo.GetCommit", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
commitCache[sha] = commit
|
||||
@@ -215,7 +215,7 @@ func processBlameParts(ctx *context.Context, blameParts []*git.BlamePart) map[st
|
||||
// populate commit email addresses to later look up avatars.
|
||||
userCommits, err := gituser.GetUserCommitsByGitCommits(ctx, commits, ctx.Repo.RepoLink, ctx.Repo.RefFullName)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetUserCommitsByGitCommits", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
for _, c := range userCommits {
|
||||
|
||||
@@ -52,7 +52,7 @@ func Branches(ctx *context.Context) {
|
||||
|
||||
defaultBranchOptional, branches, branchesCount, err := repo_service.LoadBranches(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, ctx.Doer, ctx.Repo.Permission, optional.None[bool](), kw, page, pageSize)
|
||||
if err != nil {
|
||||
ctx.ServerError("LoadBranches", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func Branches(ctx *context.Context) {
|
||||
|
||||
commitStatuses, err := git_model.GetLatestCommitStatusForRepoCommitIDs(ctx, ctx.Repo.Repository.ID, commitIDs)
|
||||
if err != nil {
|
||||
ctx.ServerError("LoadBranches", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ func RestoreBranchPost(ctx *context.Context) {
|
||||
func CreateBranch(ctx *context.Context) {
|
||||
form := web.GetForm[*forms.NewBranchForm](ctx)
|
||||
if !ctx.Repo.CanCreateBranch() {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ func CreateBranch(ctx *context.Context) {
|
||||
"Details": utils.EscapeFlashErrorString(e.Message),
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("UpdatePullRequest.HTMLString", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Flash.Error(flashError)
|
||||
@@ -216,7 +216,7 @@ func CreateBranch(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
ctx.ServerError("CreateNewBranch", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ func MergeUpstream(ctx *context.Context) {
|
||||
ctx.JSONError(ctx.Tr("repo.pulls.unrelated_histories"))
|
||||
return
|
||||
}
|
||||
ctx.ServerError("MergeUpstream", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.JSONRedirect("")
|
||||
|
||||
@@ -34,7 +34,7 @@ func CodeFrequencyData(ctx *context.Context) {
|
||||
ctx.Status(http.StatusAccepted)
|
||||
return
|
||||
}
|
||||
ctx.ServerError("GetContributorStats", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
} else {
|
||||
ctx.JSON(http.StatusOK, contributorStats["total"].Weeks)
|
||||
}
|
||||
|
||||
+25
-34
@@ -5,7 +5,6 @@
|
||||
package repo
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -59,7 +58,7 @@ func RefCommits(ctx *context.Context) {
|
||||
func Commits(ctx *context.Context) {
|
||||
ctx.Data["PageIsCommits"] = true
|
||||
if ctx.Repo.Commit == nil {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
ctx.Data["PageIsViewCode"] = true
|
||||
@@ -76,12 +75,12 @@ func Commits(ctx *context.Context) {
|
||||
// Both `git log branchName` and `git log commitId` work.
|
||||
commits, err := ctx.Repo.Commit.CommitsByRange(ctx, ctx.Repo.GitRepo, page, pageSize, "", "", "")
|
||||
if err != nil {
|
||||
ctx.ServerError("CommitsByRange", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Commits"], err = processGitCommits(ctx, commits)
|
||||
if err != nil {
|
||||
ctx.ServerError("processGitCommits", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
commitIDs := make([]string, 0, len(commits))
|
||||
@@ -136,7 +135,7 @@ func Graph(ctx *context.Context) {
|
||||
graphCommitsCount, err = ctx.Repo.GetCommitGraphsCount(ctx, hidePRRefs, branchRefs, files)
|
||||
}
|
||||
if err != nil {
|
||||
ctx.ServerError("GetCommitGraphsCount", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -144,12 +143,12 @@ func Graph(ctx *context.Context) {
|
||||
page := ctx.FormInt("page")
|
||||
graph, err := gitgraph.GetCommitGraph(ctx, ctx.Repo.GitRepo, page, 0, hidePRRefs, branchRefs, files)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetCommitGraph", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := graph.LoadAndProcessCommits(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo); err != nil {
|
||||
ctx.ServerError("LoadAndProcessCommits", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -157,7 +156,7 @@ func Graph(ctx *context.Context) {
|
||||
|
||||
gitRefs, err := ctx.Repo.GitRepo.GetRefs(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("GitRepo.GetRefs", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -190,13 +189,13 @@ func SearchCommits(ctx *context.Context) {
|
||||
opts := git.NewSearchCommitsOptions(query, all)
|
||||
commits, err := ctx.Repo.Commit.SearchCommits(ctx, ctx.Repo.GitRepo, opts)
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchCommits", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["CommitCount"] = len(commits)
|
||||
ctx.Data["Commits"], err = processGitCommits(ctx, commits)
|
||||
if err != nil {
|
||||
ctx.ServerError("processGitCommits", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -227,7 +226,7 @@ func FileHistory(ctx *context.Context) {
|
||||
FollowRename: followRename,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("CommitsByFileAndRange", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -238,13 +237,13 @@ func FileHistory(ctx *context.Context) {
|
||||
} else {
|
||||
commitsCount, err = git.FileCommitsCount(ctx, ctx.Repo.Repository, ctx.Repo.RefFullName.ShortName(), ctx.Repo.TreePath)
|
||||
if err != nil {
|
||||
ctx.ServerError("FileCommitsCount", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if len(commits) == 0 {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -252,7 +251,7 @@ func FileHistory(ctx *context.Context) {
|
||||
ctx.Data["CommitCount"] = commitsCount
|
||||
ctx.Data["Commits"], err = processGitCommits(ctx, commits)
|
||||
if err != nil {
|
||||
ctx.ServerError("processGitCommits", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -270,7 +269,7 @@ func LoadBranchesAndTags(ctx *context.Context) {
|
||||
ctx.JSON(http.StatusOK, response)
|
||||
return
|
||||
}
|
||||
ctx.ServerError("LoadBranchesAndTags", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
|
||||
// Diff show different from current commit to previous commit
|
||||
@@ -292,7 +291,7 @@ func Diff(ctx *context.Context) {
|
||||
var err error
|
||||
gitRepo, err = git.RepositoryFromRequestContextOrOpen(ctx, ctx.Repo.Repository.WikiStorageRepo())
|
||||
if err != nil {
|
||||
ctx.ServerError("Repo.GitRepo.GetCommit", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
diffBlobExcerptData.BaseLink = ctx.Repo.RepoLink + "/wiki/blob_excerpt"
|
||||
@@ -300,11 +299,7 @@ func Diff(ctx *context.Context) {
|
||||
|
||||
commit, err := gitRepo.GetCommit(ctx, commitID)
|
||||
if err != nil {
|
||||
if git.IsErrNotExist(err) {
|
||||
ctx.NotFound(err)
|
||||
} else {
|
||||
ctx.ServerError("Repo.GitRepo.GetCommit", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if len(commitID) != commit.ID.Type().FullLength() {
|
||||
@@ -330,12 +325,12 @@ func Diff(ctx *context.Context) {
|
||||
MaxFiles: maxFiles,
|
||||
}, files...)
|
||||
if err != nil {
|
||||
ctx.NotFound(err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
diffShortStat, err := gitdiff.GetDiffShortStat(ctx, gitRepo, &diffCommonOptions)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDiffShortStat", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["DiffShortStat"] = diffShortStat
|
||||
@@ -344,7 +339,7 @@ func Diff(ctx *context.Context) {
|
||||
for i := 0; i < commit.ParentCount(); i++ {
|
||||
sha, err := commit.ParentID(i)
|
||||
if err != nil {
|
||||
ctx.NotFound(err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
parents[i] = sha.String()
|
||||
@@ -358,7 +353,7 @@ func Diff(ctx *context.Context) {
|
||||
if commit.ParentCount() > 0 {
|
||||
parentCommit, err = gitRepo.GetCommit(ctx, parents[0])
|
||||
if err != nil {
|
||||
ctx.NotFound(err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
parentCommitID = parentCommit.ID.String()
|
||||
@@ -372,7 +367,7 @@ func Diff(ctx *context.Context) {
|
||||
if !fileOnly {
|
||||
diffTree, err := gitdiff.GetDiffTree(ctx, gitRepo, false, parentCommitID, commitID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDiffTree", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -403,7 +398,7 @@ func Diff(ctx *context.Context) {
|
||||
if err := asymkey_model.CalculateTrustStatus(verification, ctx.Repo.Repository.GetTrustModel(), func(user *user_model.User) (bool, error) {
|
||||
return repo_model.HasAccessToRepoCodeUnit(ctx, ctx.Repo.Repository, user.ID)
|
||||
}, nil); err != nil {
|
||||
ctx.ServerError("CalculateTrustStatus", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -432,7 +427,7 @@ func RawDiff(ctx *context.Context) {
|
||||
if ctx.Data["PageIsWiki"] != nil {
|
||||
wikiRepo, err := git.OpenRepository(ctx, ctx.Repo.Repository.WikiStorageRepo())
|
||||
if err != nil {
|
||||
ctx.ServerError("OpenRepository", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
defer wikiRepo.Close()
|
||||
@@ -440,7 +435,7 @@ func RawDiff(ctx *context.Context) {
|
||||
} else {
|
||||
gitRepo = ctx.Repo.GitRepo
|
||||
if gitRepo == nil {
|
||||
ctx.ServerError("GitRepo not open", fmt.Errorf("no open git repo for '%s'", ctx.Repo.Repository.FullName()))
|
||||
ctx.ServerErrorAuto(fmt.Errorf("no open git repo for '%s'", ctx.Repo.Repository.FullName()))
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -450,11 +445,7 @@ func RawDiff(ctx *context.Context) {
|
||||
git.RawDiffType(ctx.PathParam("ext")),
|
||||
ctx.Resp,
|
||||
); err != nil {
|
||||
if git.IsErrNotExist(err) {
|
||||
ctx.NotFound(errors.New("commit " + ctx.PathParam("sha") + " does not exist."))
|
||||
return
|
||||
}
|
||||
ctx.ServerError("GetRawDiff", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
+21
-21
@@ -436,12 +436,12 @@ func (cpi *comparePageInfoType) prepareCompareDiff(ctx *context.Context, whitesp
|
||||
MaxFiles: maxFiles,
|
||||
}, ctx.FormStrings("files")...)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDiff", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
diffShortStat, err := gitdiff.GetDiffShortStat(ctx, ci.HeadGitRepo, &diffCommonOptions)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDiffShortStat", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["DiffShortStat"] = diffShortStat
|
||||
@@ -457,7 +457,7 @@ func (cpi *comparePageInfoType) prepareCompareDiff(ctx *context.Context, whitesp
|
||||
if !fileOnly {
|
||||
diffTree, err := gitdiff.GetDiffTree(ctx, ci.HeadGitRepo, false, beforeCommitID, headCommitID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDiffTree", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -470,7 +470,7 @@ func (cpi *comparePageInfoType) prepareCompareDiff(ctx *context.Context, whitesp
|
||||
|
||||
headCommit, err := ci.HeadGitRepo.GetCommit(ctx, headCommitID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetCommit", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -478,13 +478,13 @@ func (cpi *comparePageInfoType) prepareCompareDiff(ctx *context.Context, whitesp
|
||||
|
||||
beforeCommit, err := baseGitRepo.GetCommit(ctx, beforeCommitID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetCommit", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
commits, err := processGitCommits(ctx, ci.Commits)
|
||||
if err != nil {
|
||||
ctx.ServerError("processGitCommits", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Commits"] = commits
|
||||
@@ -516,10 +516,10 @@ func CompareDiff(ctx *context.Context) {
|
||||
comparePageInfo := newComparePageInfo()
|
||||
err := comparePageInfo.parseCompareInfo(ctx, ctx.PathParam("*"))
|
||||
if errors.Is(err, util.ErrNotExist) || errors.Is(err, util.ErrInvalidArgument) {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
} else if err != nil {
|
||||
ctx.ServerError("ParseCompareInfo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ci := comparePageInfo.compareInfo
|
||||
@@ -535,7 +535,7 @@ func CompareDiff(ctx *context.Context) {
|
||||
|
||||
baseTags, err := repo_model.GetTagNamesByRepoID(ctx, ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetTagNamesByRepoID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Tags"] = baseTags
|
||||
@@ -548,7 +548,7 @@ func CompareDiff(ctx *context.Context) {
|
||||
|
||||
headBranches, headTags, err := getBranchesAndTagsForRepo(ctx, ci.HeadRepo)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetBranchesAndTagsForRepo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["HeadBranches"] = headBranches
|
||||
@@ -593,9 +593,9 @@ func downloadCompareDiffOrPatch(ctx *context.Context, patch bool) {
|
||||
cpi := newComparePageInfo()
|
||||
if err := cpi.parseCompareInfo(ctx, ctx.PathParam("basehead")); err != nil {
|
||||
if errors.Is(err, util.ErrNotExist) || errors.Is(err, util.ErrInvalidArgument) {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
} else {
|
||||
ctx.ServerError("ParseCompareInfo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -611,7 +611,7 @@ func downloadCompareDiffOrPatch(ctx *context.Context, patch bool) {
|
||||
err = ci.HeadGitRepo.GetDiff(ctx, compareArg, ctx.Resp)
|
||||
}
|
||||
if err != nil {
|
||||
ctx.ServerError("DownloadCompareDiffOrPatch", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -622,13 +622,13 @@ func (cpi *comparePageInfoType) prepareCreatePullRequestPage(ctx *context.Contex
|
||||
pr, err := issues_model.GetUnmergedPullRequest(ctx, ci.HeadRepo.ID, ctx.Repo.Repository.ID, ci.HeadRef.ShortName(), ci.BaseRef.ShortName(), issues_model.PullRequestFlowGithub)
|
||||
if err != nil {
|
||||
if !issues_model.IsErrPullRequestNotExist(err) {
|
||||
ctx.ServerError("GetUnmergedPullRequest", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
ctx.Data["HasPullRequest"] = true
|
||||
if err := pr.LoadIssue(ctx); err != nil {
|
||||
ctx.ServerError("LoadIssue", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["PullRequest"] = pr
|
||||
@@ -736,7 +736,7 @@ func ExcerptBlob(ctx *context.Context) {
|
||||
var err error
|
||||
gitRepo, err = git.RepositoryFromRequestContextOrOpen(ctx, ctx.Repo.Repository.WikiStorageRepo())
|
||||
if err != nil {
|
||||
ctx.ServerError("OpenRepository", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
diffBlobExcerptData.BaseLink = ctx.Repo.RepoLink + "/wiki/blob_excerpt"
|
||||
@@ -744,31 +744,31 @@ func ExcerptBlob(ctx *context.Context) {
|
||||
|
||||
commit, err := gitRepo.GetCommit(ctx, commitID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetCommit", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
blob, err := commit.GetBlobByPath(ctx, gitRepo, filePath)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetBlobByPath", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
reader, err := blob.DataAsync(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("DataAsync", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
defer reader.Close()
|
||||
|
||||
section, err := gitdiff.BuildBlobExcerptDiffSection(filePath, reader, opts)
|
||||
if err != nil {
|
||||
ctx.ServerError("BuildBlobExcerptDiffSection", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
diffBlobExcerptData.PullIssueIndex = ctx.FormInt64("pull_issue_index")
|
||||
if diffBlobExcerptData.PullIssueIndex > 0 {
|
||||
if !ctx.Repo.Permission.CanRead(unit.TypePullRequests) {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ func ContributorsData(ctx *context.Context) {
|
||||
ctx.Status(http.StatusAccepted)
|
||||
return
|
||||
}
|
||||
ctx.ServerError("GetContributorStats", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
} else {
|
||||
ctx.JSON(http.StatusOK, contributorStats)
|
||||
}
|
||||
|
||||
@@ -69,22 +69,18 @@ func ServeBlobOrLFS(ctx *context.Context, blob *git.Blob, lastModified *time.Tim
|
||||
func getBlobForEntry(ctx *context.Context) (*git.Blob, *time.Time) {
|
||||
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(ctx, ctx.Repo.GitRepo, ctx.Repo.TreePath)
|
||||
if err != nil {
|
||||
if git.IsErrNotExist(err) {
|
||||
ctx.NotFound(err)
|
||||
} else {
|
||||
ctx.ServerError("GetTreeEntryByPath", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if entry.IsDir() || entry.IsSubModule() {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
latestCommit, err := ctx.Repo.GitRepo.GetTreePathLatestCommit(ctx, ctx.Repo.Commit.ID.String(), ctx.Repo.TreePath)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetTreePathLatestCommit", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, nil
|
||||
}
|
||||
lastModified := &latestCommit.Committer.When
|
||||
@@ -104,7 +100,7 @@ func SingleDownload(ctx *context.Context) {
|
||||
}
|
||||
|
||||
if err := common.ServeBlob(ctx.Base, ctx.Repo.Repository, ctx.Repo.TreePath, blob, lastModified); err != nil {
|
||||
ctx.ServerError("ServeBlob", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +116,7 @@ func SingleDownloadOrLFS(ctx *context.Context) {
|
||||
}
|
||||
|
||||
if err := ServeBlobOrLFS(ctx, blob, lastModified); err != nil {
|
||||
ctx.ServerError("ServeBlobOrLFS", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,15 +128,11 @@ func DownloadByID(ctx *context.Context) {
|
||||
|
||||
blob, err := ctx.Repo.GitRepo.GetBlob(ctx.PathParam("sha"))
|
||||
if err != nil {
|
||||
if git.IsErrNotExist(err) {
|
||||
ctx.NotFound(nil)
|
||||
} else {
|
||||
ctx.ServerError("GetBlob", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if err = common.ServeBlob(ctx.Base, ctx.Repo.Repository, ctx.Repo.TreePath, blob, nil); err != nil {
|
||||
ctx.ServerError("ServeBlob", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,14 +144,10 @@ func DownloadByIDOrLFS(ctx *context.Context) {
|
||||
|
||||
blob, err := ctx.Repo.GitRepo.GetBlob(ctx.PathParam("sha"))
|
||||
if err != nil {
|
||||
if git.IsErrNotExist(err) {
|
||||
ctx.NotFound(nil)
|
||||
} else {
|
||||
ctx.ServerError("GetBlob", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if err = ServeBlobOrLFS(ctx, blob, nil); err != nil {
|
||||
ctx.ServerError("ServeBlob", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
}
|
||||
+13
-18
@@ -15,7 +15,6 @@ import (
|
||||
"gitea.dev/models/issues"
|
||||
"gitea.dev/models/unit"
|
||||
"gitea.dev/modules/charset"
|
||||
"gitea.dev/modules/git"
|
||||
"gitea.dev/modules/httplib"
|
||||
"gitea.dev/modules/log"
|
||||
"gitea.dev/modules/setting"
|
||||
@@ -58,7 +57,7 @@ func prepareEditorPageFormOptions(ctx *context.Context, editorAction string) *co
|
||||
|
||||
commitFormOptions, err := context.PrepareCommitFormOptions(ctx, ctx.Doer, ctx.Repo.Repository, ctx.Repo.Permission, ctx.Repo.RefFullName)
|
||||
if err != nil {
|
||||
ctx.ServerError("PrepareCommitFormOptions", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -69,7 +68,7 @@ func prepareEditorPageFormOptions(ctx *context.Context, editorAction string) *co
|
||||
|
||||
if commitFormOptions.WillSubmitToFork && !commitFormOptions.TargetRepo.CanContentChange() {
|
||||
ctx.Data["NotFoundPrompt"] = ctx.Locale.Tr("repo.editor.fork_not_editable")
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
}
|
||||
|
||||
ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.RefTypeNameSubURL()
|
||||
@@ -123,7 +122,7 @@ func prepareEditorCommitSubmittedForm[T forms.CommitCommonFormInterface](ctx *co
|
||||
|
||||
commitFormOptions, err := context.PrepareCommitFormOptions(ctx, ctx.Doer, ctx.Repo.Repository, ctx.Repo.Permission, ctx.Repo.RefFullName)
|
||||
if err != nil {
|
||||
ctx.ServerError("PrepareCommitFormOptions", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
if commitFormOptions.NeedFork {
|
||||
@@ -135,7 +134,7 @@ func prepareEditorCommitSubmittedForm[T forms.CommitCommonFormInterface](ctx *co
|
||||
// check commit behavior
|
||||
fromBaseBranch := ctx.FormString("from_base_branch")
|
||||
if fromBaseBranch != "" && ctx.Repo.Repository.BaseRepo == nil {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return nil
|
||||
}
|
||||
commitToNewBranch := commonForm.CommitChoice == editorCommitChoiceNewBranch || fromBaseBranch != ""
|
||||
@@ -146,7 +145,7 @@ func prepareEditorCommitSubmittedForm[T forms.CommitCommonFormInterface](ctx *co
|
||||
}
|
||||
|
||||
if !issues.CanMaintainerWriteToBranch(ctx, ctx.Repo.Permission, targetBranchName, ctx.Doer) {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -161,7 +160,7 @@ func prepareEditorCommitSubmittedForm[T forms.CommitCommonFormInterface](ctx *co
|
||||
// if target branch exists, we should stop
|
||||
targetBranchExists, err := git_model.IsBranchExist(ctx, commitFormOptions.TargetRepo.ID, targetBranchName)
|
||||
if err != nil {
|
||||
ctx.ServerError("IsBranchExist", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
} else if targetBranchExists {
|
||||
if fromBaseBranch != "" {
|
||||
@@ -230,24 +229,20 @@ func redirectForCommitChoice[T any](ctx *context.Context, parsed *preparedEditor
|
||||
func editFileOpenExisting(ctx *context.Context) (prefetch []byte, dataRc io.ReadCloser, fInfo *fileInfo) {
|
||||
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(ctx, ctx.Repo.GitRepo, ctx.Repo.TreePath)
|
||||
if err != nil {
|
||||
HandleGitError(ctx, "GetTreeEntryByPath", err)
|
||||
HandleGitError(ctx, err)
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
// No way to edit a directory online.
|
||||
if entry.IsDir() {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
blob := entry.Blob(ctx.Repo.GitRepo)
|
||||
buf, dataRc, fInfo, err := getFileReader(ctx, ctx.Repo.Repository.ID, blob)
|
||||
if err != nil {
|
||||
if git.IsErrNotExist(err) {
|
||||
ctx.NotFound(err)
|
||||
} else {
|
||||
ctx.ServerError("getFileReader", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
@@ -255,11 +250,11 @@ func editFileOpenExisting(ctx *context.Context) (prefetch []byte, dataRc io.Read
|
||||
lfsLock, err := git_model.GetTreePathLock(ctx, ctx.Repo.Repository.ID, ctx.Repo.TreePath)
|
||||
if err != nil {
|
||||
_ = dataRc.Close()
|
||||
ctx.ServerError("GetTreePathLock", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, nil, nil
|
||||
} else if lfsLock != nil && lfsLock.OwnerID != ctx.Doer.ID {
|
||||
_ = dataRc.Close()
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return nil, nil, nil
|
||||
}
|
||||
}
|
||||
@@ -316,7 +311,7 @@ func EditFile(ctx *context.Context) {
|
||||
if ctx.Data["NotEditableReason"] == nil {
|
||||
buf, err := io.ReadAll(io.MultiReader(bytes.NewReader(prefetch), dataRc))
|
||||
if err != nil {
|
||||
ctx.ServerError("ReadAll", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["FileContent"] = string(charset.ToUTF8(buf, charset.ConvertOpts{KeepBOM: true, ErrorReturnOrigin: true}))
|
||||
@@ -409,7 +404,7 @@ func DeleteFilePost(ctx *context.Context) {
|
||||
// Check if the path is a directory
|
||||
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(ctx, ctx.Repo.GitRepo, treePath)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetTreeEntryByPath", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ func CherryPick(ctx *context.Context) {
|
||||
ctx.Data["FromCommitID"] = fromCommitID
|
||||
cherryPickCommit, err := ctx.Repo.GitRepo.GetCommit(ctx, fromCommitID)
|
||||
if err != nil {
|
||||
HandleGitError(ctx, "GetCommit", err)
|
||||
HandleGitError(ctx, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ func DiffPreviewPost(ctx *context.Context) {
|
||||
|
||||
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(ctx, ctx.Repo.GitRepo, treePath)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetTreeEntryByPath", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
} else if entry.IsDir() {
|
||||
ctx.HTTPError(http.StatusUnprocessableEntity)
|
||||
@@ -30,12 +30,12 @@ func DiffPreviewPost(ctx *context.Context) {
|
||||
|
||||
oldContent, err := entry.Blob(ctx.Repo.GitRepo).GetBlobContent(ctx, setting.UI.MaxDisplayFileSize)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetBlobContent", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
diff, err := files_service.GetDiffPreview(ctx, ctx.Repo.Repository, ctx.Repo.BranchName, treePath, oldContent, newContent)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDiffPreview", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
func UploadFileToServer(ctx *context.Context) {
|
||||
file, header, err := ctx.Req.FormFile("file")
|
||||
if err != nil {
|
||||
ctx.ServerError("FormFile", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
@@ -45,7 +45,7 @@ func UploadFileToServer(ctx *context.Context) {
|
||||
|
||||
uploaded, err := repo_model.NewUpload(ctx, name, buf, file)
|
||||
if err != nil {
|
||||
ctx.ServerError("NewUpload", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ func UploadFileToServer(ctx *context.Context) {
|
||||
func RemoveUploadFileFromServer(ctx *context.Context) {
|
||||
fileUUID := ctx.FormString("file")
|
||||
if err := repo_model.DeleteUploadByUUID(ctx, fileUUID); err != nil {
|
||||
ctx.ServerError("DeleteUploadByUUID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Status(http.StatusNoContent)
|
||||
|
||||
@@ -37,12 +37,12 @@ func getForkRepository(ctx *context.Context) *repo_model.Repository {
|
||||
|
||||
if forkRepo.IsEmpty {
|
||||
log.Trace("Empty repository %-v", forkRepo)
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := forkRepo.LoadOwner(ctx); err != nil {
|
||||
ctx.ServerError("LoadOwner", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func getForkRepository(ctx *context.Context) *repo_model.Repository {
|
||||
|
||||
ownedOrgs, err := organization.GetOrgsCanCreateRepoByUserID(ctx, ctx.Doer.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetOrgsCanCreateRepoByUserID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
var orgs []*organization.Organization
|
||||
@@ -79,7 +79,7 @@ func getForkRepository(ctx *context.Context) *repo_model.Repository {
|
||||
}
|
||||
traverseParentRepo, err = repo_model.GetRepositoryByID(ctx, traverseParentRepo.ForkID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRepositoryByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ func getForkRepository(ctx *context.Context) *repo_model.Repository {
|
||||
ExcludeBranchNames: []string{ctx.Repo.Repository.DefaultBranch},
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("FindBranchNames", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
ctx.Data["Branches"] = append([]string{ctx.Repo.Repository.DefaultBranch}, branches...)
|
||||
@@ -168,7 +168,7 @@ func ForkPost(ctx *context.Context) {
|
||||
}
|
||||
traverseParentRepo, err = repo_model.GetRepositoryByID(ctx, traverseParentRepo.ForkID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRepositoryByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -177,7 +177,7 @@ func ForkPost(ctx *context.Context) {
|
||||
if ctxUser.IsOrganization() {
|
||||
isAllowedToFork, err := organization.OrgFromUser(ctxUser).CanCreateOrgRepo(ctx, ctx.Doer.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("CanCreateOrgRepo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
} else if !isAllowedToFork {
|
||||
ctx.HTTPError(http.StatusForbidden)
|
||||
@@ -219,7 +219,7 @@ func ForkRepoTo(ctx *context.Context, owner *user_model.User, forkOpts repo_serv
|
||||
case errors.Is(err, user_model.ErrBlockedUser):
|
||||
ctx.JSONError(ctx.Tr("repo.fork.blocked_user"))
|
||||
default:
|
||||
ctx.ServerError("ForkPost", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ func httpBase(ctx *context.Context, optGitService ...string) *serviceHandler {
|
||||
repo, err := repo_model.GetRepositoryByName(ctx, owner.ID, repoName)
|
||||
if err != nil {
|
||||
if !repo_model.IsErrRepoNotExist(err) {
|
||||
ctx.ServerError("GetRepositoryByName", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ func httpBase(ctx *context.Context, optGitService ...string) *serviceHandler {
|
||||
if !canAnonymousPull && ctx.Doer == nil {
|
||||
anonPerm, err := access_model.GetDoerRepoPermission(ctx, repo, nil)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDoerRepoPermission", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
canAnonymousPull = anonPerm.CanAccess(accessMode, unitType)
|
||||
@@ -172,7 +172,7 @@ func httpBase(ctx *context.Context, optGitService ...string) *serviceHandler {
|
||||
ctx.PlainText(http.StatusUnauthorized, "Users with two-factor authentication enabled cannot perform HTTP/HTTPS operations via plain username and password. Please create and use a personal access token on the user settings page")
|
||||
return nil
|
||||
} else if !auth_model.IsErrTwoFactorNotEnrolled(err) {
|
||||
ctx.ServerError("IsErrTwoFactorNotEnrolled", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -190,7 +190,7 @@ func httpBase(ctx *context.Context, optGitService ...string) *serviceHandler {
|
||||
|
||||
p, err := access_model.GetDoerRepoPermission(ctx, repo, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDoerRepoPermission", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ func httpBase(ctx *context.Context, optGitService ...string) *serviceHandler {
|
||||
ctx.PlainText(http.StatusForbidden, "repository wiki is disabled")
|
||||
return nil
|
||||
}
|
||||
ctx.ServerError("GetUnit(UnitTypeWiki) for "+repo.FullName(), err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -478,7 +478,7 @@ func GetInfoRefs(ctx *context.Context) {
|
||||
// it's said that some legacy git clients will send requests to "/info/refs" without "service" parameter,
|
||||
// although there should be no such case client in the modern days. TODO: not quite sure why we need this UpdateServerInfo logic
|
||||
if err := git.UpdateServerInfo(ctx, repo); err != nil {
|
||||
ctx.ServerError("UpdateServerInfo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
h.sendFile(ctx, "text/plain; charset=utf-8", "info/refs")
|
||||
@@ -496,7 +496,7 @@ func GetInfoRefs(ctx *context.Context) {
|
||||
|
||||
repoExists, err := git.IsRepositoryExist(ctx, repo)
|
||||
if err != nil {
|
||||
ctx.ServerError("IsRepositoryExist", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -514,7 +514,7 @@ func GetInfoRefs(ctx *context.Context) {
|
||||
cmd = cmd.AddArguments("--stateless-rpc", "--advertise-refs", ".").WithEnv(gitCmdEnvs)
|
||||
refs, _, err := cmd.WithRepo(repo).RunStdBytes(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("RunGitServiceAdvertiseRefs", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,10 @@ import (
|
||||
"gitea.dev/services/context"
|
||||
)
|
||||
|
||||
func HandleGitError(ctx *context.Context, msg string, err error) {
|
||||
func HandleGitError(ctx *context.Context, 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(err)
|
||||
} else {
|
||||
ctx.ServerError(msg, err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
+30
-30
@@ -77,7 +77,7 @@ var IssueTemplateCandidates = []string{
|
||||
func MustEnableIssues(ctx *context.Context) {
|
||||
if !ctx.Repo.Permission.CanRead(unit.TypeIssues) &&
|
||||
!ctx.Repo.Permission.CanRead(unit.TypeExternalTracker) {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -94,7 +94,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.Permission.CanRead(unit.TypePullRequests) {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ func retrieveProjectsInternal(ctx *context.Context, repo *repo_model.Repository)
|
||||
Type: project_model.TypeRepository,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetProjects", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, nil
|
||||
}
|
||||
closedProjects, err = db.Find[project_model.Project](ctx, project_model.SearchOptions{
|
||||
@@ -131,7 +131,7 @@ func retrieveProjectsInternal(ctx *context.Context, repo *repo_model.Repository)
|
||||
Type: project_model.TypeRepository,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetProjects", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
@@ -144,7 +144,7 @@ func retrieveProjectsInternal(ctx *context.Context, repo *repo_model.Repository)
|
||||
Type: repoOwnerType,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetProjects", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, nil
|
||||
}
|
||||
openProjects = append(openProjects, openProjects2...)
|
||||
@@ -155,7 +155,7 @@ func retrieveProjectsInternal(ctx *context.Context, repo *repo_model.Repository)
|
||||
Type: repoOwnerType,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetProjects", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, nil
|
||||
}
|
||||
closedProjects = append(closedProjects, closedProjects2...)
|
||||
@@ -167,17 +167,17 @@ func retrieveProjectsInternal(ctx *context.Context, repo *repo_model.Repository)
|
||||
func GetActionIssue(ctx *context.Context, accessModeOpt ...perm.AccessMode) *issues_model.Issue {
|
||||
issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
|
||||
if err != nil {
|
||||
ctx.ServerError("GetIssueByIndex", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
issue.Repo = ctx.Repo.Repository
|
||||
accessMode := util.OptionalArg(accessModeOpt, perm.AccessModeRead)
|
||||
if !ctx.Repo.Permission.CanAccess(accessMode, util.Iif(issue.IsPull, unit.TypePullRequests, unit.TypeIssues)) {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return nil
|
||||
}
|
||||
if err = issue.LoadAttributes(ctx); err != nil {
|
||||
ctx.ServerError("LoadAttributes", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
return issue
|
||||
@@ -187,21 +187,21 @@ func getActionIssues(ctx *context.Context, accessMode perm.AccessMode) issues_mo
|
||||
issueIDs := ctx.FormStringInt64s("issue_ids")
|
||||
issues, err := issues_model.GetIssuesByIDs(ctx, issueIDs)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetIssuesByIDs", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
for _, issue := range issues {
|
||||
if issue.RepoID != ctx.Repo.Repository.ID {
|
||||
ctx.NotFound(errors.New("some issue's RepoID is incorrect"))
|
||||
ctx.NotFound()
|
||||
return nil
|
||||
}
|
||||
issue.Repo = ctx.Repo.Repository
|
||||
if !ctx.Repo.Permission.CanAccess(accessMode, util.Iif(issue.IsPull, unit.TypePullRequests, unit.TypeIssues)) {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return nil
|
||||
}
|
||||
if err = issue.LoadAttributes(ctx); err != nil {
|
||||
ctx.ServerError("LoadAttributes", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -259,7 +259,7 @@ func UpdateIssueTitle(ctx *context.Context) {
|
||||
}
|
||||
|
||||
if err := issue_service.ChangeTitle(ctx, issue, ctx.Doer, title); err != nil {
|
||||
ctx.ServerError("ChangeTitle", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ func UpdateIssueRef(ctx *context.Context) {
|
||||
ref := ctx.FormTrim("ref")
|
||||
|
||||
if err := issue_service.ChangeIssueRef(ctx, issue, ctx.Doer, ref); err != nil {
|
||||
ctx.ServerError("ChangeRef", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ func UpdateIssueContent(ctx *context.Context) {
|
||||
ctx.JSONError(ctx.Tr("repo.issues.edit.already_changed"))
|
||||
}
|
||||
} else {
|
||||
ctx.ServerError("ChangeContent", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -322,7 +322,7 @@ func UpdateIssueContent(ctx *context.Context) {
|
||||
// when update the request doesn't intend to update attachments (eg: change checkbox state), ignore attachment updates
|
||||
if !ctx.FormBool("ignore_attachments") {
|
||||
if err := updateAttachments(ctx, issue, ctx.FormStrings("files[]")); err != nil {
|
||||
ctx.ServerError("UpdateAttachments", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -332,7 +332,7 @@ func UpdateIssueContent(ctx *context.Context) {
|
||||
})
|
||||
content, err := markdown.RenderString(rctx, issue.Content)
|
||||
if err != nil {
|
||||
ctx.ServerError("RenderString", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ 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(err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
} else {
|
||||
ctx.HTTPError(http.StatusInternalServerError, "GetIssueByIndex", err.Error())
|
||||
}
|
||||
@@ -387,14 +387,14 @@ func UpdateIssueMilestone(ctx *context.Context) {
|
||||
var err error
|
||||
issue.Milestone, err = issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, milestoneID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetMilestoneByRepoID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
issue.Milestone = nil
|
||||
}
|
||||
if err := issue_service.ChangeMilestoneAssign(ctx, issue, ctx.Doer, oldMilestoneID); err != nil {
|
||||
ctx.ServerError("ChangeMilestoneAssign", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -416,19 +416,19 @@ func UpdateIssueAssignee(ctx *context.Context) {
|
||||
switch action {
|
||||
case "clear":
|
||||
if err := issue_service.DeleteNotPassedAssignee(ctx, issue, ctx.Doer, []*user_model.User{}); err != nil {
|
||||
ctx.ServerError("ClearAssignees", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
default:
|
||||
assignee, err := user_model.GetUserByID(ctx, assigneeID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetUserByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
valid, err := access_model.CanBeAssigned(ctx, assignee, issue.Repo)
|
||||
if err != nil {
|
||||
ctx.ServerError("canBeAssigned", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if !valid {
|
||||
@@ -438,7 +438,7 @@ func UpdateIssueAssignee(ctx *context.Context) {
|
||||
|
||||
_, _, err = issue_service.ToggleAssigneeWithNotify(ctx, issue, ctx.Doer, assigneeID)
|
||||
if err != nil {
|
||||
ctx.ServerError("ToggleAssignee", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -474,7 +474,7 @@ func ChangeIssueReaction(ctx *context.Context) {
|
||||
reaction, err := issue_service.CreateIssueReaction(ctx, ctx.Doer, issue, form.Content)
|
||||
if err != nil {
|
||||
if issues_model.IsErrForbiddenIssueReaction(err) || errors.Is(err, user_model.ErrBlockedUser) {
|
||||
ctx.ServerError("ChangeIssueReaction", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
log.Info("CreateIssueReaction: %s", err)
|
||||
@@ -490,7 +490,7 @@ func ChangeIssueReaction(ctx *context.Context) {
|
||||
log.Trace("Reaction for issue created: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, reaction.ID)
|
||||
case "unreact":
|
||||
if err := issues_model.DeleteIssueReaction(ctx, ctx.Doer.ID, issue.ID, form.Content); err != nil {
|
||||
ctx.ServerError("DeleteIssueReaction", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -503,7 +503,7 @@ func ChangeIssueReaction(ctx *context.Context) {
|
||||
|
||||
log.Trace("Reaction for issue removed: %d/%d", ctx.Repo.Repository.ID, issue.ID)
|
||||
default:
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -517,7 +517,7 @@ func renderReactions(ctx *context.Context, actionURL string, reactions issues_mo
|
||||
"AllowedReactions": allowedReactions,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("RenderToHTML", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK, map[string]any{"html": html})
|
||||
@@ -593,7 +593,7 @@ func attachmentsHTML(ctx *context.Context, attachments []*repo_model.Attachment,
|
||||
"Content": content,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("attachmentsHTML.HTMLString", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return ""
|
||||
}
|
||||
return attachHTML
|
||||
|
||||
@@ -57,7 +57,7 @@ func NewComment(ctx *context.Context) {
|
||||
if errors.Is(err, user_model.ErrBlockedUser) {
|
||||
ctx.JSONError(ctx.Tr("repo.issues.comment.blocked_user"))
|
||||
} else {
|
||||
ctx.ServerError("CreateIssueComment", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -101,7 +101,7 @@ func NewComment(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
if err := pull_service.PushToBaseRepo(ctx, pull); err != nil {
|
||||
ctx.ServerError("PushToBaseRepo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ func NewComment(ctx *context.Context) {
|
||||
}
|
||||
} else {
|
||||
if err := stopTimerIfAvailable(ctx, ctx.Doer, issue); err != nil {
|
||||
ctx.ServerError("stopTimerIfAvailable", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
log.Trace("Issue [%d] status changed to closed: %v", issue.ID, issue.IsClosed)
|
||||
@@ -142,11 +142,11 @@ func NewComment(ctx *context.Context) {
|
||||
func getRepoIssueComment(ctx *context.Context, commentID int64) *issues_model.Comment {
|
||||
comment, err := issues_model.GetCommentWithRepoID(ctx, ctx.Repo.Repository.ID, commentID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetCommentWithRepoID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
if !ctx.Repo.Permission.CanReadIssuesOrPulls(comment.Issue.IsPull) {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return nil
|
||||
}
|
||||
return comment
|
||||
@@ -192,21 +192,21 @@ func UpdateCommentContent(ctx *context.Context) {
|
||||
} else if errors.Is(err, issues_model.ErrCommentAlreadyChanged) {
|
||||
ctx.JSONError(ctx.Tr("repo.comments.edit.already_changed"))
|
||||
} else {
|
||||
ctx.ServerError("UpdateComment", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if err := comment.LoadAttachments(ctx); err != nil {
|
||||
ctx.ServerError("LoadAttachments", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
// when the update request doesn't intend to update attachments (eg: change checkbox state), ignore attachment updates
|
||||
if !ctx.FormBool("ignore_attachments") {
|
||||
if err := updateAttachments(ctx, comment, ctx.FormStrings("files[]")); err != nil {
|
||||
ctx.ServerError("UpdateAttachments", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -219,7 +219,7 @@ func UpdateCommentContent(ctx *context.Context) {
|
||||
var err error
|
||||
renderedContent, err = markdown.RenderString(rctx, comment.Content)
|
||||
if err != nil {
|
||||
ctx.ServerError("RenderString", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -239,7 +239,7 @@ func DeleteComment(ctx *context.Context) {
|
||||
}
|
||||
|
||||
if err := issue_service.DeleteComment(ctx, ctx.Doer, comment); err != nil {
|
||||
ctx.ServerError("DeleteComment", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ func ChangeCommentReaction(ctx *context.Context) {
|
||||
reaction, err := issue_service.CreateCommentReaction(ctx, ctx.Doer, comment, form.Content)
|
||||
if err != nil {
|
||||
if issues_model.IsErrForbiddenIssueReaction(err) || errors.Is(err, user_model.ErrBlockedUser) {
|
||||
ctx.ServerError("ChangeIssueReaction", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
log.Info("CreateCommentReaction: %s", err)
|
||||
@@ -275,7 +275,7 @@ func ChangeCommentReaction(ctx *context.Context) {
|
||||
log.Trace("Reaction for comment created: %d/%d/%d/%d", ctx.Repo.Repository.ID, comment.Issue.ID, comment.ID, reaction.ID)
|
||||
case "unreact":
|
||||
if err := issues_model.DeleteCommentReaction(ctx, ctx.Doer.ID, comment.Issue.ID, comment.ID, form.Content); err != nil {
|
||||
ctx.ServerError("DeleteCommentReaction", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -288,7 +288,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(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -303,13 +303,13 @@ func GetCommentAttachments(ctx *context.Context) {
|
||||
}
|
||||
|
||||
if !comment.Type.HasAttachmentSupport() {
|
||||
ctx.ServerError("GetCommentAttachments", fmt.Errorf("comment type %v does not support attachments", comment.Type))
|
||||
ctx.ServerErrorAuto(fmt.Errorf("comment type %v does not support attachments", comment.Type))
|
||||
return
|
||||
}
|
||||
|
||||
attachments := make([]*api.Attachment, 0)
|
||||
if err := comment.LoadAttachments(ctx); err != nil {
|
||||
ctx.ServerError("LoadAttachments", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
for i := 0; i < len(comment.Attachments); i++ {
|
||||
|
||||
@@ -186,7 +186,7 @@ func SoftDeleteContentHistory(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
if ctx.Doer == nil {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -202,11 +202,11 @@ func SoftDeleteContentHistory(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
if history.IssueID != issue.ID {
|
||||
ctx.NotFound(issues_model.ErrCommentNotExist{})
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
if history.CommentID != commentID {
|
||||
ctx.NotFound(issues_model.ErrCommentNotExist{})
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
if commentID != 0 {
|
||||
@@ -215,7 +215,7 @@ func SoftDeleteContentHistory(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
if comment.IssueID != issue.ID {
|
||||
ctx.NotFound(issues_model.ErrCommentNotExist{})
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ func AddDependency(ctx *context.Context) {
|
||||
issueIndex := ctx.PathParamInt64("index")
|
||||
issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, issueIndex)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetIssueByIndex", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ func AddDependency(ctx *context.Context) {
|
||||
depID := ctx.FormInt64("newDependency")
|
||||
|
||||
if err = issue.LoadRepo(ctx); err != nil {
|
||||
ctx.ServerError("LoadRepo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -46,13 +46,13 @@ func AddDependency(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
if err := dep.LoadRepo(ctx); err != nil {
|
||||
ctx.ServerError("loadRepo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
// Can ctx.Doer read issues in the dep repo?
|
||||
depRepoPerm, err := access_model.GetDoerRepoPermission(ctx, dep.Repo, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDoerRepoPermission", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if !depRepoPerm.CanReadIssuesOrPulls(dep.IsPull) {
|
||||
@@ -75,7 +75,7 @@ func AddDependency(ctx *context.Context) {
|
||||
ctx.JSONError(ctx.Tr("repo.issues.dependency.add_error_cannot_create_circular"))
|
||||
return
|
||||
} else if err != nil {
|
||||
ctx.ServerError("CreateOrUpdateIssueDependency", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.JSONOK()
|
||||
@@ -86,7 +86,7 @@ func RemoveDependency(ctx *context.Context) {
|
||||
issueIndex := ctx.PathParamInt64("index")
|
||||
issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, issueIndex)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetIssueByIndex", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ func RemoveDependency(ctx *context.Context) {
|
||||
depID := ctx.FormInt64("removeDependencyID")
|
||||
|
||||
if err = issue.LoadRepo(ctx); err != nil {
|
||||
ctx.ServerError("LoadRepo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ func RemoveDependency(ctx *context.Context) {
|
||||
// Dependency
|
||||
dep, err := issues_model.GetIssueByID(ctx, depID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetIssueByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -130,12 +130,12 @@ func RemoveDependency(ctx *context.Context) {
|
||||
// doer can read the dependency's repository.
|
||||
if issue.RepoID != dep.RepoID {
|
||||
if err := dep.LoadRepo(ctx); err != nil {
|
||||
ctx.ServerError("loadRepo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
depRepoPerm, err := access_model.GetDoerRepoPermission(ctx, dep.Repo, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDoerRepoPermission", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if !depRepoPerm.CanReadIssuesOrPulls(dep.IsPull) {
|
||||
@@ -149,7 +149,7 @@ func RemoveDependency(ctx *context.Context) {
|
||||
ctx.JSONError(ctx.Tr("repo.issues.dependency.add_error_dep_not_exist"))
|
||||
return
|
||||
} else if err != nil {
|
||||
ctx.ServerError("RemoveIssueDependency", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.JSONOK()
|
||||
|
||||
@@ -51,7 +51,7 @@ func InitializeLabels(ctx *context.Context) {
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/labels")
|
||||
return
|
||||
}
|
||||
ctx.ServerError("InitializeLabels", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/labels")
|
||||
@@ -61,7 +61,7 @@ func InitializeLabels(ctx *context.Context) {
|
||||
func RetrieveLabelsForList(ctx *context.Context) {
|
||||
labels, err := issues_model.GetLabelsByRepoID(ctx, ctx.Repo.Repository.ID, ctx.FormString("sort"), db.ListOptions{})
|
||||
if err != nil {
|
||||
ctx.ServerError("RetrieveLabelsForList.GetLabels", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ func RetrieveLabelsForList(ctx *context.Context) {
|
||||
if ctx.Repo.Owner.IsOrganization() {
|
||||
orgLabels, err := issues_model.GetLabelsByOrgID(ctx, ctx.Repo.Owner.ID, ctx.FormString("sort"), db.ListOptions{})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetLabelsByOrgID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
for _, l := range orgLabels {
|
||||
@@ -94,13 +94,13 @@ func RetrieveLabelsForList(ctx *context.Context) {
|
||||
|
||||
org, err := organization.GetOrgByName(ctx, ctx.Repo.Owner.LowerName)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetOrgByName", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if ctx.Doer != nil {
|
||||
ctx.Org.IsOwner, err = org.IsOwnedBy(ctx, ctx.Doer.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("org.IsOwnedBy", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Org.OrgLink = org.AsUser().OrganisationLink()
|
||||
@@ -128,7 +128,7 @@ func NewLabel(ctx *context.Context) {
|
||||
Color: form.Color,
|
||||
}
|
||||
if err := issues_model.NewLabel(ctx, l); err != nil {
|
||||
ctx.ServerError("NewLabel", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.JSONRedirect(ctx.Repo.RepoLink + "/labels")
|
||||
@@ -146,7 +146,7 @@ func UpdateLabel(ctx *context.Context) {
|
||||
ctx.JSONErrorNotFound()
|
||||
return
|
||||
} else if err != nil {
|
||||
ctx.ServerError("GetLabelInRepoByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ func UpdateLabel(ctx *context.Context) {
|
||||
l.Color = form.Color
|
||||
l.SetArchived(form.IsArchived)
|
||||
if err := issues_model.UpdateLabel(ctx, l); err != nil {
|
||||
ctx.ServerError("UpdateLabel", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.JSONRedirect(ctx.Repo.RepoLink + "/labels")
|
||||
@@ -185,7 +185,7 @@ func UpdateIssueLabel(ctx *context.Context) {
|
||||
case "clear":
|
||||
for _, issue := range issues {
|
||||
if err := issue_service.ClearLabels(ctx, issue, ctx.Doer); err != nil {
|
||||
ctx.ServerError("ClearLabels", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -197,7 +197,7 @@ func UpdateIssueLabel(ctx *context.Context) {
|
||||
if errors.Is(err, util.ErrNotExist) {
|
||||
ctx.HTTPError(http.StatusNotFound, "GetLabelByID")
|
||||
} else {
|
||||
ctx.ServerError("GetLabelByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -222,14 +222,14 @@ func UpdateIssueLabel(ctx *context.Context) {
|
||||
if action == "attach" {
|
||||
for _, issue := range issues {
|
||||
if err = issue_service.AddLabel(ctx, issue, ctx.Doer, label); err != nil {
|
||||
ctx.ServerError("AddLabel", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, issue := range issues {
|
||||
if err = issue_service.RemoveLabel(ctx, issue, ctx.Doer, label); err != nil {
|
||||
ctx.ServerError("RemoveLabel", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ func SearchGlobalIssues(ctx *context.Context) {
|
||||
if errors.Is(err, util.ErrNotExist) || errors.Is(err, util.ErrInvalidArgument) {
|
||||
ctx.HTTPError(http.StatusBadRequest, err.Error())
|
||||
} else {
|
||||
ctx.ServerError("SearchIssuesRepoIDs", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -81,7 +81,7 @@ func SearchGlobalIssues(ctx *context.Context) {
|
||||
}
|
||||
includedAnyLabels, err = issues_model.GetLabelIDsByNames(ctx, includedLabelNames)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetLabelIDsByNames", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,7 @@ func SearchGlobalIssues(ctx *context.Context) {
|
||||
}
|
||||
includedMilestones, err = issues_model.GetMilestoneIDsByNames(ctx, includedMilestoneNames)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetMilestoneIDsByNames", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -159,12 +159,12 @@ func SearchGlobalIssues(ctx *context.Context) {
|
||||
|
||||
ids, total, err := issue_indexer.SearchIssues(ctx, searchOpt)
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchIssues", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
issues, err := issues_model.GetIssuesByIDs(ctx, ids, true)
|
||||
if err != nil {
|
||||
ctx.ServerError("FindIssuesByIDs", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ func getUserIDForFilter(ctx *context.Context, queryName string) int64 {
|
||||
|
||||
user, err := user_model.GetUserByName(ctx, userName)
|
||||
if user_model.IsErrUserNotExist(err) {
|
||||
ctx.NotFound(err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ func BatchDeleteIssues(ctx *context.Context) {
|
||||
}
|
||||
for _, issue := range issues {
|
||||
if err := issue_service.DeleteIssue(ctx, ctx.Doer, issue); err != nil {
|
||||
ctx.ServerError("DeleteIssue", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -342,11 +342,11 @@ func UpdateIssueStatus(ctx *context.Context) {
|
||||
}
|
||||
|
||||
if _, err := issues.LoadRepositories(ctx); err != nil {
|
||||
ctx.ServerError("LoadRepositories", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if err := issues.LoadPullRequests(ctx); err != nil {
|
||||
ctx.ServerError("LoadPullRequests", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -360,12 +360,12 @@ func UpdateIssueStatus(ctx *context.Context) {
|
||||
ctx.JSONError(ctx.Tr("repo.issues.dependency.issue_batch_close_blocked", issue.Index))
|
||||
return
|
||||
}
|
||||
ctx.ServerError("CloseIssue", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
} else if action == "open" && issue.IsClosed {
|
||||
if err := issue_service.ReopenIssue(ctx, issue, ctx.Doer, ""); err != nil {
|
||||
ctx.ServerError("ReopenIssue", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -393,7 +393,7 @@ func renderMilestones(ctx *context.Context, projectID int64) {
|
||||
ProjectID: projectID,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetAllRepoMilestones", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -469,7 +469,7 @@ func prepareIssueFilterAndList(ctx *context.Context, milestoneID int64, projectI
|
||||
keywordMatchedIssueIDs, _, err = issue_indexer.SearchIssues(ctx, issue_indexer.ToSearchOptions(keyword, statsOpts))
|
||||
if err != nil {
|
||||
if issue_indexer.IsAvailable(ctx) {
|
||||
ctx.ServerError("issueIDsFromSearch", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["IssueIndexerUnavailable"] = true
|
||||
@@ -489,7 +489,7 @@ func prepareIssueFilterAndList(ctx *context.Context, milestoneID int64, projectI
|
||||
// Or the keyword is empty, so it doesn't need issueIDs as filter, just get issueStats with statsOpts.
|
||||
issueStats, err = issues_model.GetIssueStats(ctx, statsOpts)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetIssueStats", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -504,7 +504,7 @@ func prepareIssueFilterAndList(ctx *context.Context, milestoneID int64, projectI
|
||||
if repo.IsTimetrackerEnabled(ctx) {
|
||||
totalTrackedTime, err := issues_model.GetIssueTotalTrackedTime(ctx, statsOpts, isShowClosed)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetIssueTotalTrackedTime", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["TotalTrackedTime"] = totalTrackedTime
|
||||
@@ -544,26 +544,26 @@ func prepareIssueFilterAndList(ctx *context.Context, milestoneID int64, projectI
|
||||
IssueIDs: keywordMatchedIssueIDs,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("DBIndexer.Search", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
issueIDs := issue_indexer.SearchResultToIDSlice(searchResult)
|
||||
issues, err = issues_model.GetIssuesByIDs(ctx, issueIDs, true)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetIssuesByIDs", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
approvalCounts, err := issues.GetApprovalCounts(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("ApprovalCounts", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.IsSigned {
|
||||
if err := issues.LoadIsRead(ctx, ctx.Doer.ID); err != nil {
|
||||
ctx.ServerError("LoadIsRead", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@@ -574,12 +574,12 @@ func prepareIssueFilterAndList(ctx *context.Context, milestoneID int64, projectI
|
||||
|
||||
commitStatuses, lastStatus, err := pull_service.GetIssuesAllCommitStatus(ctx, ctx.Doer, issues)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetIssuesAllCommitStatus", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := issues.LoadAttributes(ctx); err != nil {
|
||||
ctx.ServerError("issues.LoadAttributes", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -590,7 +590,7 @@ func prepareIssueFilterAndList(ctx *context.Context, milestoneID int64, projectI
|
||||
// Get assignees.
|
||||
assigneeUsers, err := repo_model.GetRepoAssignees(ctx, repo)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRepoAssignees", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Assignees"] = shared_user.MakeSelfOnTop(ctx.Doer, assigneeUsers)
|
||||
@@ -624,7 +624,7 @@ func prepareIssueFilterAndList(ctx *context.Context, milestoneID int64, projectI
|
||||
|
||||
pinned, err := issues_model.GetPinnedIssues(ctx, repo.ID, isPullOption.Value())
|
||||
if err != nil {
|
||||
ctx.ServerError("GetPinnedIssues", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ func LockIssue(ctx *context.Context) {
|
||||
Issue: issue,
|
||||
Reason: form.Reason,
|
||||
}); err != nil {
|
||||
ctx.ServerError("LockIssue", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ func UnlockIssue(ctx *context.Context) {
|
||||
Doer: ctx.Doer,
|
||||
Issue: issue,
|
||||
}); err != nil {
|
||||
ctx.ServerError("UnlockIssue", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ func NewIssue(ctx *context.Context) {
|
||||
restriction := ctx.Repo.Repository.MustGetUnit(ctx, unit.TypeIssues).IssuesConfig().CreationRestriction
|
||||
err := issue_service.CheckCreationRestriction(ctx.Repo.Permission, unit.TypeIssues, restriction)
|
||||
if err != nil {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ func NewIssue(ctx *context.Context) {
|
||||
|
||||
tags, err := repo_model.GetTagNamesByRepoID(ctx, ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetTagNamesByRepoID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Tags"] = tags
|
||||
@@ -218,7 +218,7 @@ func DeleteIssue(ctx *context.Context) {
|
||||
}
|
||||
|
||||
if err := issue_service.DeleteIssue(ctx, ctx.Doer, issue); err != nil {
|
||||
ctx.ServerError("DeleteIssueByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ func ValidateRepoMetasForCreateIssue(ctx *context.Context, form forms.CreateIssu
|
||||
inputLabelIDs := ctx.FormStringInt64s("label_ids")
|
||||
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()
|
||||
return ret
|
||||
}
|
||||
pageMetaData.LabelsData.SetSelectedLabelIDs(inputLabelIDs)
|
||||
@@ -264,7 +264,7 @@ func ValidateRepoMetasForCreateIssue(ctx *context.Context, form forms.CreateIssu
|
||||
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()
|
||||
return ret
|
||||
}
|
||||
pageMetaData.MilestonesData.SelectedMilestoneID = form.MilestoneID
|
||||
@@ -273,7 +273,7 @@ func ValidateRepoMetasForCreateIssue(ctx *context.Context, form forms.CreateIssu
|
||||
allProjects := slices.Concat(pageMetaData.ProjectsData.OpenProjects, pageMetaData.ProjectsData.ClosedProjects)
|
||||
candidateProjects := toSet(allProjects, func(project *project_model.Project) int64 { return project.ID })
|
||||
if len(inputProjectIDs) > 0 && !candidateProjects.Contains(inputProjectIDs...) {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return ret
|
||||
}
|
||||
pageMetaData.SetSelectedProjectIDs(inputProjectIDs)
|
||||
@@ -306,14 +306,14 @@ func ValidateRepoMetasForCreateIssue(ctx *context.Context, form forms.CreateIssu
|
||||
if rID < 0 { // negative reviewIDs represent team requests
|
||||
team, ok := teamReviewersMap[-rID]
|
||||
if !ok {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return ret
|
||||
}
|
||||
teamReviewers = append(teamReviewers, team)
|
||||
} else {
|
||||
user, ok := userReviewersMap[rID]
|
||||
if !ok {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return ret
|
||||
}
|
||||
reviewers = append(reviewers, user)
|
||||
|
||||
@@ -229,7 +229,7 @@ func (d *IssuePageMetaData) retrieveMilestonesDataForIssueWriter(ctx *context.Co
|
||||
IsClosed: optional.Some(false),
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetMilestones", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
d.MilestonesData.ClosedMilestones, err = db.Find[issues_model.Milestone](ctx, issues_model.FindMilestoneOptions{
|
||||
@@ -237,7 +237,7 @@ func (d *IssuePageMetaData) retrieveMilestonesDataForIssueWriter(ctx *context.Co
|
||||
IsClosed: optional.Some(true),
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetMilestones", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -246,7 +246,7 @@ func (d *IssuePageMetaData) retrieveAssigneesData(ctx *context.Context) {
|
||||
var err error
|
||||
d.AssigneesData.CandidateAssignees, err = repo_model.GetRepoAssignees(ctx, d.Repository)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRepoAssignees", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
d.AssigneesData.CandidateAssignees = shared_user.MakeSelfOnTop(ctx.Doer, d.AssigneesData.CandidateAssignees)
|
||||
@@ -263,14 +263,14 @@ func (d *IssuePageMetaData) retrieveAssigneesData(ctx *context.Context) {
|
||||
|
||||
func (d *IssuePageMetaData) retrieveProjectCardsForExistingIssue(ctx *context.Context) {
|
||||
if err := d.Issue.LoadProjects(ctx); err != nil {
|
||||
ctx.ServerError("LoadProjects", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
// Load column mappings for all projects
|
||||
projectColumnMap, err := d.Issue.ProjectColumnMap(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("ProjectColumnMap", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ func (d *IssuePageMetaData) retrieveProjectCardsForExistingIssue(ctx *context.Co
|
||||
for _, project := range d.Issue.Projects {
|
||||
columns, err := project_model.GetColumns(ctx, project.ID, db.ListOptionsAll)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetColumns", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ func (d *IssuePageMetaData) retrieveProjectCardsForExistingIssue(ctx *context.Co
|
||||
if selectedColumn == nil {
|
||||
selectedColumn, err = project.MustDefaultColumn(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("MustDefaultColumn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -389,7 +389,7 @@ func (d *IssuePageMetaData) retrieveReviewersData(ctx *context.Context) {
|
||||
|
||||
reviews, data.OriginalReviews, err = issues_model.GetReviewsByIssueID(ctx, d.Issue.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetReviewersByIssueID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if len(reviews) == 0 && !data.CanChooseReviewer {
|
||||
@@ -409,13 +409,13 @@ func (d *IssuePageMetaData) retrieveReviewersData(ctx *context.Context) {
|
||||
var err error
|
||||
reviewers, err = pull_service.GetReviewers(ctx, repo, ctx.Doer.ID, posterID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetReviewers", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
teamReviewers, err = pull_service.GetReviewerTeams(ctx, repo)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetReviewerTeams", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -459,20 +459,20 @@ func (d *IssuePageMetaData) retrieveReviewersData(ctx *context.Context) {
|
||||
|
||||
if len(pullReviews) > 0 {
|
||||
if err := reviews.LoadReviewers(ctx); err != nil {
|
||||
ctx.ServerError("LoadReviewers", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
currentPullReviewers := make([]*repoReviewerSelection, 0, len(pullReviews))
|
||||
for _, item := range pullReviews {
|
||||
if item.Review.ReviewerID > 0 {
|
||||
if err := item.Review.LoadReviewer(ctx); err != nil {
|
||||
ctx.ServerError("LoadReviewer", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
item.User = item.Review.Reviewer
|
||||
} else if item.Review.ReviewerTeamID > 0 {
|
||||
if err := item.Review.LoadReviewerTeam(ctx); err != nil {
|
||||
ctx.ServerError("LoadReviewerTeam", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
item.Team = item.Review.ReviewerTeam
|
||||
@@ -597,7 +597,7 @@ func (d *IssuePageMetaData) retrieveLabelsData(ctx *context.Context) {
|
||||
|
||||
labels, err := issues_model.GetLabelsByRepoID(ctx, repo.ID, "", db.ListOptions{})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetLabelsByRepoID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
issues_model.SortLabelsForDisplay(labels)
|
||||
|
||||
@@ -23,14 +23,14 @@ func IssuePinOrUnpin(ctx *context.Context) {
|
||||
// If we don't do this, it will crash when trying to add the pin event to the comment history
|
||||
err := issue.LoadRepo(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("LoadRepo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
// PinOrUnpin pins or unpins a Issue
|
||||
_, err = issues_model.GetIssuePin(ctx, issue)
|
||||
if err != nil && !db.IsErrNotExist(err) {
|
||||
ctx.ServerError("GetIssuePin", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ func IssuePinOrUnpin(ctx *context.Context) {
|
||||
if issues_model.IsErrIssueMaxPinReached(err) {
|
||||
ctx.JSONError(ctx.Tr("repo.issues.max_pinned"))
|
||||
} else {
|
||||
ctx.ServerError("Pin/Unpin failed", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -56,20 +56,20 @@ func IssuePinOrUnpin(ctx *context.Context) {
|
||||
func IssueUnpin(ctx *context.Context) {
|
||||
issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
|
||||
if err != nil {
|
||||
ctx.ServerError("GetIssueByIndex", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
// If we don't do this, it will crash when trying to add the pin event to the comment history
|
||||
err = issue.LoadRepo(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("LoadRepo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
err = issues_model.UnpinIssue(ctx, issue, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("UnpinIssue", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -90,13 +90,13 @@ func IssuePinMove(ctx *context.Context) {
|
||||
|
||||
form := &movePinIssueForm{}
|
||||
if err := json.NewDecoder(ctx.Req.Body).Decode(&form); err != nil {
|
||||
ctx.ServerError("Decode", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
issue, err := issues_model.GetIssueByID(ctx, form.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetIssueByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ func IssuePinMove(ctx *context.Context) {
|
||||
|
||||
err = issues_model.MovePin(ctx, issue, form.Position)
|
||||
if err != nil {
|
||||
ctx.ServerError("MovePin", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -17,12 +17,12 @@ func IssueStartStopwatch(c *context.Context) {
|
||||
}
|
||||
|
||||
if !c.Repo.CanUseTimetracker(c, issue, c.Doer) {
|
||||
c.NotFound(nil)
|
||||
c.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
if ok, err := issues_model.CreateIssueStopwatch(c, c.Doer, issue); err != nil {
|
||||
c.ServerError("CreateIssueStopwatch", err)
|
||||
c.ServerErrorAuto(err)
|
||||
return
|
||||
} else if !ok {
|
||||
c.Flash.Warning(c.Tr("repo.issues.stopwatch_already_created"))
|
||||
@@ -41,12 +41,12 @@ func IssueStopStopwatch(c *context.Context) {
|
||||
}
|
||||
|
||||
if !c.Repo.CanUseTimetracker(c, issue, c.Doer) {
|
||||
c.NotFound(nil)
|
||||
c.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
if ok, err := issues_model.FinishIssueStopwatch(c, c.Doer, issue); err != nil {
|
||||
c.ServerError("FinishIssueStopwatch", err)
|
||||
c.ServerErrorAuto(err)
|
||||
return
|
||||
} else if !ok {
|
||||
c.Flash.Warning(c.Tr("repo.issues.stopwatch_already_stopped"))
|
||||
@@ -63,12 +63,12 @@ func CancelStopwatch(c *context.Context) {
|
||||
return
|
||||
}
|
||||
if !c.Repo.CanUseTimetracker(c, issue, c.Doer) {
|
||||
c.NotFound(nil)
|
||||
c.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := issues_model.CancelStopwatch(c, c.Doer, issue); err != nil {
|
||||
c.ServerError("CancelStopwatch", err)
|
||||
c.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ func IssueSuggestions(ctx *context.Context) {
|
||||
|
||||
suggestions, err := issue_service.GetSuggestion(ctx, ctx.Repo.Repository, isPull, keyword)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetSuggestion", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ func AddTimeManually(c *context.Context) {
|
||||
return
|
||||
}
|
||||
if !c.Repo.CanUseTimetracker(c, issue, c.Doer) {
|
||||
c.NotFound(nil)
|
||||
c.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ func AddTimeManually(c *context.Context) {
|
||||
}
|
||||
|
||||
if _, err := issues_model.AddTime(c, c.Doer, issue, int64(total.Seconds()), time.Now()); err != nil {
|
||||
c.ServerError("AddTime", err)
|
||||
c.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -56,14 +56,14 @@ func DeleteTime(c *context.Context) {
|
||||
return
|
||||
}
|
||||
if !c.Repo.CanUseTimetracker(c, issue, c.Doer) {
|
||||
c.NotFound(nil)
|
||||
c.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
t, err := issues_model.GetTrackedTimeByID(c, issue.ID, c.PathParamInt64("timeid"))
|
||||
if err != nil {
|
||||
if db.IsErrNotExist(err) {
|
||||
c.NotFound(err)
|
||||
c.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
c.HTTPError(http.StatusInternalServerError, "GetTrackedTimeByID", err.Error())
|
||||
@@ -77,7 +77,7 @@ func DeleteTime(c *context.Context) {
|
||||
}
|
||||
|
||||
if err = issues_model.DeleteTime(c, t); err != nil {
|
||||
c.ServerError("DeleteTime", err)
|
||||
c.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ func UpdateIssueTimeEstimate(ctx *context.Context) {
|
||||
}
|
||||
|
||||
if err := issue_service.ChangeTimeEstimate(ctx, issue, ctx.Doer, total); err != nil {
|
||||
ctx.ServerError("ChangeTimeEstimate", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ func checkBlockedByIssues(ctx *context.Context, blockers []*issues_model.Depende
|
||||
var err error
|
||||
perm, err = access_model.GetDoerRepoPermission(ctx, &blocker.Repository, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDoerRepoPermission", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, nil
|
||||
}
|
||||
repoPerms[blocker.RepoID] = perm
|
||||
@@ -268,14 +268,14 @@ func combineLabelComments(issue *issues_model.Issue) {
|
||||
func prepareIssueViewLoad(ctx *context.Context) *issues_model.Issue {
|
||||
issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("index"))
|
||||
if err != nil {
|
||||
ctx.ServerError("GetIssueByIndex", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
issue.Repo = ctx.Repo.Repository
|
||||
ctx.Data["Issue"] = issue
|
||||
|
||||
if err = issue.LoadPullRequest(ctx); err != nil {
|
||||
ctx.ServerError("LoadPullRequest", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
return issue
|
||||
@@ -292,14 +292,14 @@ func handleViewIssueRedirectExternal(ctx *context.Context) {
|
||||
res, err := vars.ExpandCurlyBrace(extIssueUnit.ExternalTrackerConfig().ExternalTrackerFormat, metas)
|
||||
if err != nil {
|
||||
log.Error("unable to expand template vars for issue url. issue: %s, err: %v", metas["index"], err)
|
||||
ctx.ServerError("Expand", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Redirect(res)
|
||||
return
|
||||
}
|
||||
} else if err != nil && !repo_model.IsErrUnitTypeNotExist(err) {
|
||||
ctx.ServerError("GetUnit", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -347,13 +347,13 @@ func ViewIssue(ctx *context.Context) {
|
||||
upload.AddUploadContext(ctx, "comment")
|
||||
|
||||
if err := issue.LoadAttributes(ctx); err != nil {
|
||||
ctx.ServerError("LoadAttributes", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
var err error
|
||||
if issue.Comments, err = issue_service.FilterReadableComments(ctx, ctx.Doer, ctx.Repo.Permission, issue, issue.Comments); err != nil {
|
||||
ctx.ServerError("FilterReadableComments", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
combineXRefComments(issue)
|
||||
@@ -363,7 +363,7 @@ func ViewIssue(ctx *context.Context) {
|
||||
if ctx.IsSigned {
|
||||
// Update issue-user.
|
||||
if err := notifications.SetIssueReadBy(ctx, issue.ID, ctx.Doer.ID); err != nil {
|
||||
ctx.ServerError("ReadBy", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -416,7 +416,7 @@ func ViewIssue(ctx *context.Context) {
|
||||
|
||||
tags, err := repo_model.GetTagNamesByRepoID(ctx, ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetTagNamesByRepoID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Tags"] = tags
|
||||
@@ -438,7 +438,7 @@ func ViewPullMergeBox(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
if !issue.IsPull {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
prViewInfo := newPullRequestViewInfo()
|
||||
@@ -476,7 +476,7 @@ func prepareIssueViewSidebarDependency(ctx *context.Context, issue *issues_model
|
||||
// Get Dependencies
|
||||
blockedBy, _, err := issue.BlockedByDependencies(ctx, db.ListOptions{})
|
||||
if err != nil {
|
||||
ctx.ServerError("BlockedByDependencies", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["BlockedByDependencies"], ctx.Data["BlockedByDependenciesNotPermitted"] = checkBlockedByIssues(ctx, blockedBy)
|
||||
@@ -486,7 +486,7 @@ func prepareIssueViewSidebarDependency(ctx *context.Context, issue *issues_model
|
||||
|
||||
blocking, err := issue.BlockingDependencies(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("BlockingDependencies", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -553,7 +553,7 @@ func prepareIssueViewSidebarWatch(ctx *context.Context, issue *issues_model.Issu
|
||||
var err error
|
||||
iw.IsWatching, err = issues_model.CheckIssueWatch(ctx, ctx.Doer, issue)
|
||||
if err != nil {
|
||||
ctx.ServerError("CheckIssueWatch", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -572,7 +572,7 @@ func prepareIssueViewSidebarTimeTracker(ctx *context.Context, issue *issues_mode
|
||||
if !isStopwatchRunning {
|
||||
exists, _, swIssue, err := issues_model.HasUserStopwatch(ctx, ctx.Doer.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("HasUserStopwatch", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["HasUserStopwatch"] = exists
|
||||
@@ -588,7 +588,7 @@ func prepareIssueViewSidebarTimeTracker(ctx *context.Context, issue *issues_mode
|
||||
}
|
||||
var err error
|
||||
if ctx.Data["WorkingUsers"], err = issues_model.TotalTimesForEachUser(ctx, &issues_model.FindTrackedTimesOptions{IssueID: issue.ID}); err != nil {
|
||||
ctx.ServerError("TotalTimesForEachUser", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -605,7 +605,7 @@ func (prInfo *pullRequestViewInfo) prepareMergeBoxDeleteBranch(ctx *context.Cont
|
||||
if isPullBranchDeletable && prInfo.issue.IsClosed {
|
||||
exist, err := issues_model.HasUnmergedPullRequestsByHeadInfo(ctx, pull.HeadRepoID, pull.HeadBranch)
|
||||
if err != nil {
|
||||
ctx.ServerError("HasUnmergedPullRequestsByHeadInfo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -617,14 +617,14 @@ func (prInfo *pullRequestViewInfo) prepareMergeBoxDeleteBranch(ctx *context.Cont
|
||||
func prepareIssueViewSidebarPin(ctx *context.Context, issue *issues_model.Issue) {
|
||||
var pinAllowed bool
|
||||
if err := issue.LoadPinOrder(ctx); err != nil {
|
||||
ctx.ServerError("LoadPinOrder", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if issue.PinOrder == 0 {
|
||||
var err error
|
||||
pinAllowed, err = issues_model.IsNewPinAllowed(ctx, issue.RepoID, issue.IsPull)
|
||||
if err != nil {
|
||||
ctx.ServerError("IsNewPinAllowed", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@@ -652,11 +652,11 @@ func prepareIssueViewCommentsAndSidebarParticipants(ctx *context.Context, issue
|
||||
participants[0] = issue.Poster
|
||||
|
||||
if err := issue.Comments.LoadAttachmentsByIssue(ctx); err != nil {
|
||||
ctx.ServerError("LoadAttachmentsByIssue", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if err := issue.Comments.LoadPosters(ctx); err != nil {
|
||||
ctx.ServerError("LoadPosters", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -671,7 +671,7 @@ func prepareIssueViewCommentsAndSidebarParticipants(ctx *context.Context, issue
|
||||
})
|
||||
comment.RenderedContent, err = markdown.RenderString(rctx, comment.Content)
|
||||
if err != nil {
|
||||
ctx.ServerError("RenderString", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
// Check tag.
|
||||
@@ -683,19 +683,19 @@ func prepareIssueViewCommentsAndSidebarParticipants(ctx *context.Context, issue
|
||||
|
||||
comment.ShowRole, err = roleDescriptor(ctx, issue.Repo, comment.Poster, permCache, issue, comment.HasOriginalAuthor())
|
||||
if err != nil {
|
||||
ctx.ServerError("roleDescriptor", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
marked[comment.PosterID] = comment.ShowRole
|
||||
participants = addParticipant(comment.Poster, participants)
|
||||
} else if comment.Type == issues_model.CommentTypeLabel {
|
||||
if err = comment.LoadLabel(ctx); err != nil {
|
||||
ctx.ServerError("LoadLabel", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
} else if comment.Type == issues_model.CommentTypeMilestone {
|
||||
if err = comment.LoadMilestone(ctx); err != nil {
|
||||
ctx.ServerError("LoadMilestone", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ghostMilestone := &issues_model.Milestone{
|
||||
@@ -710,7 +710,7 @@ func prepareIssueViewCommentsAndSidebarParticipants(ctx *context.Context, issue
|
||||
}
|
||||
} else if comment.Type == issues_model.CommentTypeProject {
|
||||
if err = comment.LoadProject(ctx); err != nil {
|
||||
ctx.ServerError("LoadProject", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -728,12 +728,12 @@ func prepareIssueViewCommentsAndSidebarParticipants(ctx *context.Context, issue
|
||||
}
|
||||
} else if comment.Type == issues_model.CommentTypeProjectColumn {
|
||||
if err = comment.LoadProject(ctx); err != nil {
|
||||
ctx.ServerError("LoadProject", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
} else if comment.Type == issues_model.CommentTypeAssignees || comment.Type == issues_model.CommentTypeReviewRequest {
|
||||
if err = comment.LoadAssigneeUserAndTeam(ctx); err != nil {
|
||||
ctx.ServerError("LoadAssigneeUserAndTeam", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
} else if comment.Type.HasContentSupport() {
|
||||
@@ -742,11 +742,11 @@ func prepareIssueViewCommentsAndSidebarParticipants(ctx *context.Context, issue
|
||||
})
|
||||
comment.RenderedContent, err = markdown.RenderString(rctx, comment.Content)
|
||||
if err != nil {
|
||||
ctx.ServerError("RenderString", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if err = comment.LoadReview(ctx); err != nil && !issues_model.IsErrReviewNotExist(err) {
|
||||
ctx.ServerError("LoadReview", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
participants = addParticipant(comment.Poster, participants)
|
||||
@@ -757,11 +757,11 @@ func prepareIssueViewCommentsAndSidebarParticipants(ctx *context.Context, issue
|
||||
comment.Review.Reviewer = comment.Poster
|
||||
}
|
||||
if err = comment.Review.LoadAttributes(ctx); err != nil {
|
||||
ctx.ServerError("Review.LoadAttributes", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if err = comment.Review.LoadCodeComments(ctx); err != nil {
|
||||
ctx.ServerError("Review.LoadCodeComments", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
for _, codeComments := range comment.Review.CodeComments {
|
||||
@@ -776,7 +776,7 @@ func prepareIssueViewCommentsAndSidebarParticipants(ctx *context.Context, issue
|
||||
|
||||
c.ShowRole, err = roleDescriptor(ctx, issue.Repo, c.Poster, permCache, issue, c.HasOriginalAuthor())
|
||||
if err != nil {
|
||||
ctx.ServerError("roleDescriptor", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
marked[c.PosterID] = c.ShowRole
|
||||
@@ -785,13 +785,13 @@ func prepareIssueViewCommentsAndSidebarParticipants(ctx *context.Context, issue
|
||||
}
|
||||
}
|
||||
if err = comment.LoadResolveDoer(ctx); err != nil {
|
||||
ctx.ServerError("LoadResolveDoer", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
} else if comment.Type == issues_model.CommentTypePullRequestPush {
|
||||
participants = addParticipant(comment.Poster, participants)
|
||||
if err = issue_service.LoadCommentPushCommits(ctx, comment); err != nil {
|
||||
ctx.ServerError("LoadCommentPushCommits", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
git_model.SignCommitsApplyDoerPermission(ctx, ctx.Doer, comment.Commits)
|
||||
@@ -830,7 +830,7 @@ func prepareIssueViewCommentsAndSidebarParticipants(ctx *context.Context, issue
|
||||
if ctx.IsSigned {
|
||||
val, err := user_model.GetUserSetting(ctx, ctx.Doer.ID, user_model.SettingsKeyHiddenCommentTypes)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetUserSetting", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
hiddenCommentTypes, _ = new(big.Int).SetString(val, 10) // we can safely ignore the failed conversion here
|
||||
@@ -872,7 +872,7 @@ func (prInfo *pullRequestViewInfo) prepareMergeBox(ctx *context.Context, issue *
|
||||
} else if pull.HeadRepo != nil {
|
||||
perm, err := access_model.GetDoerRepoPermission(ctx, pull.HeadRepo, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDoerRepoPermission", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if perm.CanWrite(unit.TypeCode) {
|
||||
@@ -895,7 +895,7 @@ func (prInfo *pullRequestViewInfo) prepareMergeBox(ctx *context.Context, issue *
|
||||
}
|
||||
perm, err := access_model.GetDoerRepoPermission(ctx, pull.BaseRepo, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDoerRepoPermission", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if !canWriteToHeadRepo { // maintainers maybe allowed to push to head repo even if they can't write to it
|
||||
@@ -903,12 +903,12 @@ func (prInfo *pullRequestViewInfo) prepareMergeBox(ctx *context.Context, issue *
|
||||
}
|
||||
data.hasPermToMerge, err = pull_service.IsUserAllowedToMerge(ctx, pull, perm, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("IsUserAllowedToMerge", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.Data["CanMarkConversation"], err = issues_model.CanMarkConversation(ctx, issue, ctx.Doer); err != nil {
|
||||
ctx.ServerError("CanMarkConversation", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -978,7 +978,7 @@ func (prInfo *pullRequestViewInfo) preparePullUpdateActions(ctx *context.Context
|
||||
data := prInfo.MergeBoxData
|
||||
userUpdateStyles, err := pull_service.CheckUserAllowedToUpdate(ctx, pull, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("IsUserAllowedToUpdate", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if !userUpdateStyles.MergeAllowed && !userUpdateStyles.RebaseAllowed {
|
||||
@@ -1015,7 +1015,7 @@ func (prInfo *pullRequestViewInfo) preparePullUpdateActions(ctx *context.Context
|
||||
func (prInfo *pullRequestViewInfo) prepareMergeBoxProtectionChecks(ctx *context.Context) {
|
||||
pb, err := git_model.GetFirstMatchProtectedBranchRule(ctx, ctx.Repo.Repository.ID, prInfo.issue.PullRequest.BaseBranch)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetFirstMatchProtectedBranchRule", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if pb != nil {
|
||||
@@ -1090,11 +1090,11 @@ func prepareIssueViewContent(ctx *context.Context, issue *issues_model.Issue) {
|
||||
})
|
||||
issue.RenderedContent, err = markdown.RenderString(rctx, issue.Content)
|
||||
if err != nil {
|
||||
ctx.ServerError("RenderString", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if issue.ShowRole, err = roleDescriptor(ctx, issue.Repo, issue.Poster, nil, issue, issue.HasOriginalAuthor()); err != nil {
|
||||
ctx.ServerError("roleDescriptor", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ func IssueWatch(ctx *context.Context) {
|
||||
|
||||
watch := ctx.FormBool("watch")
|
||||
if err := issues_model.CreateOrUpdateIssueWatch(ctx, ctx.Doer.ID, issue.ID, watch); err != nil {
|
||||
ctx.ServerError("CreateOrUpdateIssueWatch", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -23,18 +23,18 @@ func GetMentionsInRepo(ctx *context.Context) {
|
||||
if issueIndex := ctx.FormInt64("issue_index"); issueIndex > 0 {
|
||||
issue, err := issues_model.GetIssueByIndex(ctx, ctx.Repo.Repository.ID, issueIndex)
|
||||
if err != nil && !errors.Is(err, util.ErrNotExist) {
|
||||
ctx.ServerError("GetIssueByIndex", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if issue != nil {
|
||||
userIDs, err := issue.GetParticipantIDsByIssue(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetParticipantIDsByIssue", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
users, err := user_model.GetUsersByIDs(ctx, userIDs)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetUsersByIDs", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
c.AddUsers(ctx, users)
|
||||
@@ -44,14 +44,14 @@ func GetMentionsInRepo(ctx *context.Context) {
|
||||
// Get repo assignees
|
||||
assignees, err := repo_model.GetRepoAssignees(ctx, ctx.Repo.Repository)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRepoAssignees", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
c.AddUsers(ctx, assignees)
|
||||
|
||||
// Get mentionable teams for org repos
|
||||
if err := c.AddMentionableTeams(ctx, ctx.Doer, ctx.Repo.Owner); err != nil {
|
||||
ctx.ServerError("AddMentionableTeams", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ func setMigrationContextData(ctx *context.Context, serviceType structs.GitServic
|
||||
func MigrateRetryPost(ctx *context.Context) {
|
||||
if err := task.RetryMigrateTask(ctx, ctx.Repo.Repository.ID); err != nil {
|
||||
log.Error("Retry task failed: %v", err)
|
||||
ctx.ServerError("task.RetryMigrateTask", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.JSONOK()
|
||||
@@ -251,7 +251,7 @@ func MigrateCancelPost(ctx *context.Context) {
|
||||
if migratingTask.Status == structs.TaskStatusRunning {
|
||||
taskUpdate := &admin_model.Task{ID: migratingTask.ID, Status: structs.TaskStatusFailed, Message: "canceled"}
|
||||
if err = taskUpdate.UpdateCols(ctx, "status", "message"); err != nil {
|
||||
ctx.ServerError("task.UpdateCols", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,20 +51,20 @@ func Milestones(ctx *context.Context) {
|
||||
Name: keyword,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetMilestones", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
stats, err := issues_model.GetMilestonesStatsByRepoCondAndKw(ctx, builder.And(builder.Eq{"id": ctx.Repo.Repository.ID}), keyword)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetMilestoneStats", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["OpenCount"] = stats.OpenCount
|
||||
ctx.Data["ClosedCount"] = stats.ClosedCount
|
||||
if ctx.Repo.Repository.IsTimetrackerEnabled(ctx) {
|
||||
if err := issues_model.MilestoneList(miles).LoadTotalTrackedTimes(ctx); err != nil {
|
||||
ctx.ServerError("LoadTotalTrackedTimes", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func Milestones(ctx *context.Context) {
|
||||
rctx := renderhelper.NewRenderContextRepoComment(ctx, ctx.Repo.Repository)
|
||||
m.RenderedContent, err = markdown.RenderString(rctx, m.Content)
|
||||
if err != nil {
|
||||
ctx.ServerError("RenderString", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ func NewMilestonePost(ctx *context.Context) {
|
||||
Content: form.Content,
|
||||
DeadlineUnix: deadlineUnix,
|
||||
}); err != nil {
|
||||
ctx.ServerError("NewMilestone", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -143,11 +143,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)
|
||||
} else {
|
||||
ctx.ServerError("GetMilestoneByRepoID", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["title"] = m.Name
|
||||
@@ -179,18 +175,14 @@ 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)
|
||||
} else {
|
||||
ctx.ServerError("GetMilestoneByRepoID", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
m.Name = form.Title
|
||||
m.Content = form.Content
|
||||
m.DeadlineUnix = deadlineUnix
|
||||
if err = issues_model.UpdateMilestone(ctx, m, m.IsClosed); err != nil {
|
||||
ctx.ServerError("UpdateMilestone", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -213,11 +205,7 @@ func ChangeMilestoneStatus(ctx *context.Context) {
|
||||
id := ctx.PathParamInt64("id")
|
||||
|
||||
if err := issues_model.ChangeMilestoneStatusByRepoIDAndID(ctx, ctx.Repo.Repository.ID, id, toClose); err != nil {
|
||||
if issues_model.IsErrMilestoneNotExist(err) {
|
||||
ctx.NotFound(err)
|
||||
} else {
|
||||
ctx.ServerError("ChangeMilestoneStatusByIDAndRepoID", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.JSONRedirect(ctx.Repo.RepoLink + "/milestones?state=" + url.QueryEscape(ctx.PathParam("action")))
|
||||
@@ -240,19 +228,14 @@ func MilestoneIssuesAndPulls(ctx *context.Context) {
|
||||
projectIDs := parseProjectIDsFromQuery(ctx)
|
||||
milestone, err := issues_model.GetMilestoneByRepoID(ctx, ctx.Repo.Repository.ID, milestoneID)
|
||||
if err != nil {
|
||||
if issues_model.IsErrMilestoneNotExist(err) {
|
||||
ctx.NotFound(err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.ServerError("GetMilestoneByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
rctx := renderhelper.NewRenderContextRepoComment(ctx, ctx.Repo.Repository)
|
||||
milestone.RenderedContent, err = markdown.RenderString(rctx, milestone.Content)
|
||||
if err != nil {
|
||||
ctx.ServerError("RenderString", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -37,19 +37,19 @@ func Packages(ctx *context.Context) {
|
||||
IsInternal: optional.Some(false),
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchLatestVersions", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
pds, err := packages.GetPackageDescriptors(ctx, pvs)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetPackageDescriptors", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
hasPackages, err := packages.HasRepositoryPackages(ctx, ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("HasRepositoryPackages", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -44,14 +44,14 @@ const (
|
||||
// MustEnableRepoProjects check if repo projects are enabled in settings
|
||||
func MustEnableRepoProjects(ctx *context.Context) {
|
||||
if unit.TypeProjects.UnitGlobalDisabled() {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.Repo.Repository != nil {
|
||||
projectsUnit := ctx.Repo.Repository.MustGetUnit(ctx, unit.TypeProjects)
|
||||
if !ctx.Repo.Permission.CanRead(unit.TypeProjects) || !projectsUnit.ProjectsConfig().IsProjectsAllowed(repo_model.ProjectsModeRepo) {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -83,12 +83,12 @@ func Projects(ctx *context.Context) {
|
||||
Title: keyword,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetProjects", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := project_service.LoadIssueNumbersForProjects(ctx, projects, ctx.Doer); err != nil {
|
||||
ctx.ServerError("LoadIssueNumbersForProjects", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ func Projects(ctx *context.Context) {
|
||||
rctx := renderhelper.NewRenderContextRepoComment(ctx, repo)
|
||||
projects[i].RenderedContent, err = markdown.RenderString(rctx, projects[i].Description)
|
||||
if err != nil {
|
||||
ctx.ServerError("RenderString", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -150,7 +150,7 @@ func NewProjectPost(ctx *context.Context) {
|
||||
Type: project_model.TypeRepository,
|
||||
}
|
||||
if err := project_model.NewProject(ctx, project); err != nil {
|
||||
ctx.ServerError("NewProject", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
audit.Record(ctx, audit_model.ProjectCreate, ctx.Repo.Repository, "project", project.Title, "project_id", project.ID)
|
||||
@@ -174,7 +174,7 @@ func ChangeProjectStatus(ctx *context.Context) {
|
||||
id := ctx.PathParamInt64("id")
|
||||
|
||||
if err := project_model.ChangeProjectStatusByRepoIDAndID(ctx, ctx.Repo.Repository.ID, id, toClose); err != nil {
|
||||
ctx.ServerError("ChangeProjectStatusByRepoIDAndID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.JSONRedirect(project_model.ProjectLinkForRepo(ctx.Repo.Repository, id))
|
||||
@@ -184,15 +184,11 @@ func ChangeProjectStatus(ctx *context.Context) {
|
||||
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)
|
||||
} else {
|
||||
ctx.ServerError("GetProjectByID", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if p.RepoID != ctx.Repo.Repository.ID {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -215,15 +211,11 @@ 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)
|
||||
} else {
|
||||
ctx.ServerError("GetProjectByID", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if p.RepoID != ctx.Repo.Repository.ID {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -255,15 +247,11 @@ func EditProjectPost(ctx *context.Context) {
|
||||
|
||||
p, err := project_model.GetProjectByID(ctx, projectID)
|
||||
if err != nil {
|
||||
if project_model.IsErrProjectNotExist(err) {
|
||||
ctx.NotFound(nil)
|
||||
} else {
|
||||
ctx.ServerError("GetProjectByID", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if p.RepoID != ctx.Repo.Repository.ID {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -271,7 +259,7 @@ func EditProjectPost(ctx *context.Context) {
|
||||
p.Description = form.Content
|
||||
p.CardType = form.CardType
|
||||
if err = project_model.UpdateProject(ctx, p); err != nil {
|
||||
ctx.ServerError("UpdateProjects", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
audit.Record(ctx, audit_model.ProjectUpdate, ctx.Repo.Repository, "project", p.Title, "project_id", p.ID)
|
||||
@@ -288,21 +276,17 @@ func EditProjectPost(ctx *context.Context) {
|
||||
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)
|
||||
} else {
|
||||
ctx.ServerError("GetProjectByID", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if project.RepoID != ctx.Repo.Repository.ID {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
columns, err := project_model.GetColumns(ctx, project.ID, db.ListOptionsAll)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetColumns", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -328,7 +312,7 @@ func ViewProject(ctx *context.Context) {
|
||||
MilestoneIDs: milestoneIDs,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("LoadIssuesOfColumns", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
for _, column := range columns {
|
||||
@@ -349,21 +333,21 @@ func ViewProject(ctx *context.Context) {
|
||||
|
||||
linkedPrsMap, err := project_service.LoadLinkedPullRequests(ctx, issuesMap, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("LoadLinkedPullRequests", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["LinkedPRs"] = linkedPrsMap
|
||||
|
||||
labels, err := issues_model.GetLabelsByRepoID(ctx, project.RepoID, "", db.ListOptions{})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetLabelsByRepoID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.Repo.Owner.IsOrganization() {
|
||||
orgLabels, err := issues_model.GetLabelsByOrgID(ctx, ctx.Repo.Owner.ID, "", db.ListOptions{})
|
||||
if err != nil {
|
||||
ctx.ServerError("GetLabelsByOrgID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -395,7 +379,7 @@ func ViewProject(ctx *context.Context) {
|
||||
// Get assignees.
|
||||
assigneeUsers, err := repo_model.GetRepoAssignees(ctx, ctx.Repo.Repository)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRepoAssignees", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Assignees"] = shared_user.MakeSelfOnTop(ctx.Doer, assigneeUsers)
|
||||
@@ -410,7 +394,7 @@ func ViewProject(ctx *context.Context) {
|
||||
rctx := renderhelper.NewRenderContextRepoComment(ctx, ctx.Repo.Repository)
|
||||
project.RenderedContent, err = markdown.RenderString(rctx, project.Description)
|
||||
if err != nil {
|
||||
ctx.ServerError("RenderString", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -438,11 +422,11 @@ func UpdateIssueProject(ctx *context.Context) {
|
||||
}
|
||||
|
||||
if err := issues.LoadProjects(ctx); err != nil {
|
||||
ctx.ServerError("LoadProjects", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if _, err := issues.LoadRepositories(ctx); err != nil {
|
||||
ctx.ServerError("LoadProjects", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -454,7 +438,7 @@ func UpdateIssueProject(ctx *context.Context) {
|
||||
failedIssues = append(failedIssues, issue.ID)
|
||||
continue
|
||||
}
|
||||
ctx.ServerError("IssueAssignOrRemoveProject", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -470,32 +454,32 @@ func UpdateIssueProject(ctx *context.Context) {
|
||||
func UpdateIssueProjectColumn(ctx *context.Context) {
|
||||
issue, err := issues_model.GetIssueByRepoID(ctx, ctx.Repo.Repository.ID, ctx.FormInt64("issue_id"))
|
||||
if err != nil {
|
||||
ctx.ServerError("GetIssueByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if !ctx.Repo.Permission.CanWriteIssuesOrPulls(issue.IsPull) {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
column, err := project_model.GetColumn(ctx, ctx.FormInt64("id"))
|
||||
if err != nil {
|
||||
ctx.ServerError("GetColumn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := issue.LoadProjects(ctx); err != nil {
|
||||
ctx.ServerError("LoadProjects", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
// it must make sure the requested column is in this issue's projects
|
||||
if !slices.ContainsFunc(issue.Projects, func(p *project_model.Project) bool { return p.ID == column.ProjectID }) {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
if err := project_service.MoveIssueToColumn(ctx, ctx.Doer, issue, column, optional.None[int64]()); err != nil {
|
||||
ctx.ServerError("MoveIssueToColumn", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+59
-75
@@ -87,17 +87,13 @@ var pullRequestTemplateCandidates = []string{
|
||||
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(nil)
|
||||
} else {
|
||||
ctx.ServerError("GetRepositoryByID", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
|
||||
perm, err := access_model.GetDoerRepoPermission(ctx, repo, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDoerRepoPermission", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -108,7 +104,7 @@ func getRepository(ctx *context.Context, repoID int64) *repo_model.Repository {
|
||||
unit.TypeCode,
|
||||
ctx.Repo,
|
||||
perm)
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return nil
|
||||
}
|
||||
return repo
|
||||
@@ -117,19 +113,15 @@ func getRepository(ctx *context.Context, repoID int64) *repo_model.Repository {
|
||||
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(err)
|
||||
} else {
|
||||
ctx.ServerError("GetIssueByIndex", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, false
|
||||
}
|
||||
if err = issue.LoadPoster(ctx); err != nil {
|
||||
ctx.ServerError("LoadPoster", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, false
|
||||
}
|
||||
if err := issue.LoadRepo(ctx); err != nil {
|
||||
ctx.ServerError("LoadRepo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, false
|
||||
}
|
||||
ctx.Data["Title"] = fmt.Sprintf("#%d - %s", issue.Index, emoji.ReplaceAliases(issue.Title))
|
||||
@@ -141,19 +133,19 @@ func getPullInfo(ctx *context.Context) (issue *issues_model.Issue, ok bool) {
|
||||
}
|
||||
|
||||
if err = issue.LoadPullRequest(ctx); err != nil {
|
||||
ctx.ServerError("LoadPullRequest", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, false
|
||||
}
|
||||
|
||||
if err = issue.PullRequest.LoadHeadRepo(ctx); err != nil {
|
||||
ctx.ServerError("LoadHeadRepo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, false
|
||||
}
|
||||
|
||||
if ctx.IsSigned {
|
||||
// Update issue-user.
|
||||
if err := notifications.SetIssueReadBy(ctx, issue.ID, ctx.Doer.ID); err != nil {
|
||||
ctx.ServerError("ReadBy", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil, false
|
||||
}
|
||||
}
|
||||
@@ -344,12 +336,12 @@ func (prInfo *pullRequestViewInfo) prepareViewInfo(ctx *context.Context, issue *
|
||||
ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
|
||||
|
||||
if err := issue.PullRequest.LoadHeadRepo(ctx); err != nil {
|
||||
ctx.ServerError("LoadHeadRepo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := issue.PullRequest.LoadBaseRepo(ctx); err != nil {
|
||||
ctx.ServerError("LoadBaseRepo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -653,13 +645,13 @@ func ViewPullCommits(ctx *context.Context) {
|
||||
}
|
||||
prCompareInfo := &prViewInfo.CompareInfo
|
||||
if prCompareInfo.HeadCommitID == "" {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
commits, err := processGitCommits(ctx, prCompareInfo.Commits)
|
||||
if err != nil {
|
||||
ctx.ServerError("processGitCommits", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Commits"] = commits
|
||||
@@ -727,7 +719,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
|
||||
}
|
||||
prCompareInfo := &prViewInfo.CompareInfo
|
||||
if prCompareInfo.HeadCommitID == "" {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -754,7 +746,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
|
||||
if afterCommit == nil && afterCommitID == headCommitID {
|
||||
afterCommit, err = gitRepo.GetCommit(ctx, afterCommitID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetCommit(afterCommitID)", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -763,7 +755,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
|
||||
return
|
||||
}
|
||||
if afterCommit == nil {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -771,7 +763,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
|
||||
if isSingleCommit {
|
||||
beforeCommit, err = afterCommit.Parent(ctx, ctx.Repo.GitRepo, 0)
|
||||
if err != nil {
|
||||
ctx.ServerError("afterCommit.Parent", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
beforeCommitID = beforeCommit.ID.String()
|
||||
@@ -782,13 +774,13 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
|
||||
// base commit is not in the list of the pull request commits
|
||||
beforeCommit, err = gitRepo.GetCommit(ctx, beforeCommitID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetCommit(beforeCommitID)", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
if beforeCommit == nil {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -823,7 +815,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
|
||||
|
||||
diff, err := gitdiff.GetDiffForRender(ctx, ctx.Repo.RepoLink, gitRepo, diffOptions, files...)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDiff", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -836,7 +828,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
|
||||
if ctx.IsSigned && isShowAllCommits {
|
||||
reviewState, err = gitdiff.SyncUserSpecificDiff(ctx, ctx.Doer.ID, pull, gitRepo, diff, diffOptions)
|
||||
if err != nil {
|
||||
ctx.ServerError("SyncUserSpecificDiff", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if reviewState != nil {
|
||||
@@ -846,7 +838,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
|
||||
|
||||
diffShortStat, err := gitdiff.GetDiffShortStat(ctx, ctx.Repo.GitRepo, &diffCommonOptions)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDiffShortStat", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["DiffShortStat"] = diffShortStat
|
||||
@@ -858,7 +850,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
|
||||
}
|
||||
|
||||
if err = diff.LoadComments(ctx, issue, ctx.Doer, GetShowOutdatedComments(ctx)); err != nil {
|
||||
ctx.ServerError("LoadComments", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -871,7 +863,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
|
||||
}
|
||||
}
|
||||
if err := allComments.LoadAttachments(ctx); err != nil {
|
||||
ctx.ServerError("LoadAttachments", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -889,7 +881,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
|
||||
// note: use mergeBase is set to false because we already have the merge base from the pull request info
|
||||
diffTree, err := gitdiff.GetDiffTree(ctx, gitRepo, false, beforeCommitID, afterCommitID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDiffTree", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
var filesViewedState map[string]pull_model.ViewedState
|
||||
@@ -915,7 +907,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
|
||||
ctx.Data["ShowDiffSummaryInToolbar"] = diffShortStat.NumFiles != 0
|
||||
|
||||
if ctx.Data["CanMarkConversation"], err = issues_model.CanMarkConversation(ctx, issue, ctx.Doer); err != nil {
|
||||
ctx.ServerError("CanMarkConversation", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -923,7 +915,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
|
||||
|
||||
assigneeUsers, err := repo_model.GetRepoAssignees(ctx, ctx.Repo.Repository)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRepoAssignees", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Assignees"] = shared_user.MakeSelfOnTop(ctx.Doer, assigneeUsers)
|
||||
@@ -933,7 +925,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
|
||||
if ctx.Doer != nil {
|
||||
currentPendingReview, err = issues_model.GetCurrentReview(ctx, ctx.Doer, issue)
|
||||
if err != nil && !issues_model.IsErrReviewNotExist(err) {
|
||||
ctx.ServerError("GetCurrentReview", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if currentPendingReview != nil {
|
||||
@@ -943,7 +935,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
|
||||
IssueID: issue.ID,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("CountComments", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -968,7 +960,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
|
||||
}
|
||||
if isShowAllCommits && pull.Flow == issues_model.PullRequestFlowGithub {
|
||||
if err := pull.LoadHeadRepo(ctx); err != nil {
|
||||
ctx.ServerError("LoadHeadRepo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -976,7 +968,7 @@ func viewPullFiles(ctx *context.Context, beforeCommitID, afterCommitID string) {
|
||||
if !pull.HasMerged && ctx.Doer != nil {
|
||||
headPerm, err := access_model.GetDoerRepoPermission(ctx, pull.HeadRepo, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDoerRepoPermission", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1015,26 +1007,26 @@ func UpdatePullRequest(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
if issue.IsClosed {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
if issue.PullRequest.HasMerged {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
if err := issue.PullRequest.LoadBaseRepo(ctx); err != nil {
|
||||
ctx.ServerError("LoadBaseRepo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if err := issue.PullRequest.LoadHeadRepo(ctx); err != nil {
|
||||
ctx.ServerError("LoadHeadRepo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
userUpdateStyles, err := pull_service.CheckUserAllowedToUpdate(ctx, issue.PullRequest, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("IsUserAllowedToMerge", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1055,7 +1047,7 @@ func UpdatePullRequest(ctx *context.Context) {
|
||||
"Details": utils.EscapeFlashErrorString(conflictError.StdErr) + "\n" + utils.EscapeFlashErrorString(conflictError.StdOut),
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("UpdatePullRequest.HTMLString", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.JSONError(flashError)
|
||||
@@ -1067,7 +1059,7 @@ func UpdatePullRequest(ctx *context.Context) {
|
||||
"Details": utils.EscapeFlashErrorString(conflictError.StdErr) + "\n" + utils.EscapeFlashErrorString(conflictError.StdOut),
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("UpdatePullRequest.HTMLString", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.JSONError(flashError)
|
||||
@@ -1132,7 +1124,7 @@ func MergePullRequest(ctx *context.Context) {
|
||||
case errors.Is(err, pull_service.ErrDependenciesLeft):
|
||||
ctx.JSONError(ctx.Tr("repo.issues.dependency.pr_close_blocked"))
|
||||
default:
|
||||
ctx.ServerError("WebCheck", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
|
||||
return
|
||||
@@ -1147,7 +1139,7 @@ func MergePullRequest(ctx *context.Context) {
|
||||
case errors.Is(err, util.ErrInvalidArgument):
|
||||
ctx.JSONError(ctx.Tr("repo.pulls.wrong_commit_id"))
|
||||
default:
|
||||
ctx.ServerError("MergedManually", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
|
||||
return
|
||||
@@ -1162,7 +1154,7 @@ func MergePullRequest(ctx *context.Context) {
|
||||
var err error
|
||||
message, _, err = pull_service.GetDefaultMergeMessage(ctx, ctx.Repo.GitRepo, pr, repo_model.MergeStyle(form.Do))
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDefaultMergeMessage", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -1182,7 +1174,7 @@ func MergePullRequest(ctx *context.Context) {
|
||||
// schedule auto merge
|
||||
scheduled, err := automerge.ScheduleAutoMerge(ctx, ctx.Doer, pr, repo_model.MergeStyle(form.Do), message, deleteBranchAfterMerge)
|
||||
if err != nil {
|
||||
ctx.ServerError("ScheduleAutoMerge", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
} else if scheduled {
|
||||
// nothing more to do ...
|
||||
@@ -1202,7 +1194,7 @@ func MergePullRequest(ctx *context.Context) {
|
||||
"Details": utils.EscapeFlashErrorString(conflictError.StdErr) + "\n" + utils.EscapeFlashErrorString(conflictError.StdOut),
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("MergePullRequest.HTMLString", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Flash.Error(flashError)
|
||||
@@ -1214,7 +1206,7 @@ func MergePullRequest(ctx *context.Context) {
|
||||
"Details": utils.EscapeFlashErrorString(conflictError.StdErr) + "\n" + utils.EscapeFlashErrorString(conflictError.StdOut),
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("MergePullRequest.HTMLString", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Flash.Error(flashError)
|
||||
@@ -1243,14 +1235,14 @@ func MergePullRequest(ctx *context.Context) {
|
||||
"Details": utils.EscapeFlashErrorString(pushrejErr.Message),
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("MergePullRequest.HTMLString", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Flash.Error(flashError)
|
||||
}
|
||||
ctx.JSONRedirect(issue.Link())
|
||||
} else {
|
||||
ctx.ServerError("Merge", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -1260,7 +1252,7 @@ func MergePullRequest(ctx *context.Context) {
|
||||
// 1. the ctx might have been canceled ("Merge" might take a very long time and the user closes their browser)
|
||||
// 2. it is inconsistent with API/AutoMerge which all miss the call
|
||||
if err := stopTimerIfAvailable(ctx, ctx.Doer, issue); err != nil {
|
||||
ctx.ServerError("stopTimerIfAvailable", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1292,18 +1284,18 @@ func CancelAutoMergePullRequest(ctx *context.Context) {
|
||||
|
||||
exist, autoMerge, err := pull_model.GetScheduledMergeByPullID(ctx, issue.PullRequest.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetScheduledMergeByPullID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if !exist {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.Doer.ID != autoMerge.DoerID {
|
||||
allowed, err := pull_service.IsUserAllowedToMerge(ctx, issue.PullRequest, ctx.Repo.Permission, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("IsUserAllowedToMerge", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if !allowed {
|
||||
@@ -1318,7 +1310,7 @@ func CancelAutoMergePullRequest(ctx *context.Context) {
|
||||
ctx.Redirect(fmt.Sprintf("%s/pulls/%d", ctx.Repo.RepoLink, issue.Index))
|
||||
return
|
||||
}
|
||||
ctx.ServerError("RemoveScheduledAutoMerge", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Flash.Success(ctx.Tr("repo.pulls.auto_merge_canceled_schedule"))
|
||||
@@ -1339,7 +1331,7 @@ func PullsNewRedirect(ctx *context.Context) {
|
||||
baseRepo, headRepo := ctx.Repo.Repository, ctx.Repo.Repository
|
||||
if headRepo.IsFork {
|
||||
if err := headRepo.GetBaseRepo(ctx); err != nil {
|
||||
ctx.ServerError("GetBaseRepo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
baseRepo = headRepo.BaseRepo
|
||||
@@ -1385,7 +1377,7 @@ func CompareAndPullRequestPost(ctx *context.Context) {
|
||||
// Check if a pull request already exists with the same head and base branch.
|
||||
pr, err := issues_model.GetUnmergedPullRequest(ctx, ci.HeadRepo.ID, repo.ID, ci.HeadRef.ShortName(), ci.BaseRef.ShortName(), issues_model.PullRequestFlowGithub)
|
||||
if err != nil && !issues_model.IsErrPullRequestNotExist(err) {
|
||||
ctx.ServerError("GetUnmergedPullRequest", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if pr != nil {
|
||||
@@ -1449,7 +1441,7 @@ func CompareAndPullRequestPost(ctx *context.Context) {
|
||||
"Details": utils.EscapeFlashErrorString(pushrejErr.Message),
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("CompareAndPullRequest.HTMLString", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.JSONError(flashError)
|
||||
@@ -1488,18 +1480,14 @@ func DownloadPullPatch(ctx *context.Context) {
|
||||
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(err)
|
||||
} else {
|
||||
ctx.ServerError("GetPullRequestByIndex", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
binary := ctx.FormBool("binary")
|
||||
|
||||
if err := pull_service.DownloadDiffOrPatch(ctx, pr, ctx, patch, binary); err != nil {
|
||||
ctx.ServerError("DownloadDiffOrPatch", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -1572,7 +1560,7 @@ func UpdatePullRequestTarget(ctx *context.Context) {
|
||||
"user_error": errorMessage,
|
||||
})
|
||||
default:
|
||||
ctx.ServerError("UpdatePullRequestTarget", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -1589,11 +1577,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(err)
|
||||
} else {
|
||||
ctx.ServerError("GetPullRequestByIndex", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1602,7 +1586,7 @@ func SetAllowEdits(ctx *context.Context) {
|
||||
ctx.HTTPError(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
ctx.ServerError("SetAllowEdits", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ func (prInfo *pullRequestViewInfo) prepareMergeBoxFormProps(ctx *context.Context
|
||||
// Check if there is a pending pr merge
|
||||
hasPendingPullRequestMerge, pendingPullRequestMerge, err := pull_model.GetScheduledMergeByPullID(ctx, pull.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetScheduledMergeByPullID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ func RenderNewCodeCommentForm(ctx *context.Context) {
|
||||
}
|
||||
currentReview, err := issues_model.GetCurrentReview(ctx, ctx.Doer, issue)
|
||||
if err != nil && !issues_model.IsErrReviewNotExist(err) {
|
||||
ctx.ServerError("GetCurrentReview", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["PageIsPullFiles"] = true
|
||||
@@ -52,7 +52,7 @@ func RenderNewCodeCommentForm(ctx *context.Context) {
|
||||
ctx.Data["CurrentReview"] = currentReview
|
||||
pullHeadCommitID, err := ctx.Repo.GitRepo.GetRefCommitID(ctx, issue.PullRequest.GetGitHeadRefName())
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRefCommitID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["AfterCommitID"] = pullHeadCommitID
|
||||
@@ -128,23 +128,23 @@ func UpdateResolveConversation(ctx *context.Context) {
|
||||
|
||||
comment, err := issues_model.GetCommentByID(ctx, commentID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetIssueByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err = comment.LoadIssue(ctx); err != nil {
|
||||
ctx.ServerError("comment.LoadIssue", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if comment.Issue.RepoID != ctx.Repo.Repository.ID {
|
||||
ctx.NotFound(errors.New("comment's repoID is incorrect"))
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
var permResult bool
|
||||
if permResult, err = issues_model.CanMarkConversation(ctx, comment.Issue, ctx.Doer); err != nil {
|
||||
ctx.ServerError("CanMarkConversation", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if !permResult {
|
||||
@@ -160,7 +160,7 @@ func UpdateResolveConversation(ctx *context.Context) {
|
||||
if action == "Resolve" || action == "UnResolve" {
|
||||
err = issues_model.MarkConversation(ctx, comment, ctx.Doer, action == "Resolve")
|
||||
if err != nil {
|
||||
ctx.ServerError("MarkConversation", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@@ -177,7 +177,7 @@ func renderConversation(ctx *context.Context, comment *issues_model.Comment, ori
|
||||
showOutdatedComments := origin == "timeline" || GetShowOutdatedComments(ctx)
|
||||
comments, err := issues_model.FetchCodeCommentsByLine(ctx, comment.Issue, ctx.Doer, comment.TreePath, comment.Line, showOutdatedComments)
|
||||
if err != nil {
|
||||
ctx.ServerError("FetchCodeCommentsByLine", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if len(comments) == 0 {
|
||||
@@ -187,7 +187,7 @@ func renderConversation(ctx *context.Context, comment *issues_model.Comment, ori
|
||||
}
|
||||
|
||||
if err := comments.LoadAttachments(ctx); err != nil {
|
||||
ctx.ServerError("LoadAttachments", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -196,17 +196,17 @@ func renderConversation(ctx *context.Context, comment *issues_model.Comment, ori
|
||||
|
||||
ctx.Data["comments"] = comments
|
||||
if ctx.Data["CanMarkConversation"], err = issues_model.CanMarkConversation(ctx, comment.Issue, ctx.Doer); err != nil {
|
||||
ctx.ServerError("CanMarkConversation", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Issue"] = comment.Issue
|
||||
if err = comment.Issue.LoadPullRequest(ctx); err != nil {
|
||||
ctx.ServerError("comment.Issue.LoadPullRequest", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
pullHeadCommitID, err := ctx.Repo.GitRepo.GetRefCommitID(ctx, comment.Issue.PullRequest.GetGitHeadRefName())
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRefCommitID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["AfterCommitID"] = pullHeadCommitID
|
||||
@@ -248,7 +248,7 @@ func SubmitReview(ctx *context.Context) {
|
||||
reviewType := form.ReviewType()
|
||||
switch reviewType {
|
||||
case issues_model.ReviewTypeUnknown:
|
||||
ctx.ServerError("ReviewType", fmt.Errorf("unknown ReviewType: %s", form.Type))
|
||||
ctx.ServerErrorAuto(fmt.Errorf("unknown ReviewType: %s", form.Type))
|
||||
return
|
||||
|
||||
// can not approve/reject your own PR
|
||||
@@ -296,7 +296,7 @@ func DismissReview(ctx *context.Context) {
|
||||
ctx.Status(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
ctx.ServerError("pull_service.DismissReview", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ func UpdateViewedFiles(ctx *context.Context) {
|
||||
}
|
||||
|
||||
if _, err := pull_model.UpdateReviewState(ctx, ctx.Doer.ID, pull.ID, data.HeadCommitSHA, updatedFiles); err != nil {
|
||||
ctx.ServerError("UpdateReview", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ func UpdatePullReviewRequest(ctx *context.Context) {
|
||||
|
||||
for _, issue := range issues {
|
||||
if err := issue.LoadRepo(ctx); err != nil {
|
||||
ctx.ServerError("issue.LoadRepo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ func UpdatePullReviewRequest(ctx *context.Context) {
|
||||
if reviewID < 0 {
|
||||
// negative reviewIDs represent team requests
|
||||
if err := issue.Repo.LoadOwner(ctx); err != nil {
|
||||
ctx.ServerError("issue.Repo.LoadOwner", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -394,7 +394,7 @@ func UpdatePullReviewRequest(ctx *context.Context) {
|
||||
|
||||
team, err := organization.GetTeamByID(ctx, -reviewID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetTeamByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ func UpdatePullReviewRequest(ctx *context.Context) {
|
||||
ctx.Status(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
ctx.ServerError("TeamReviewRequest", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
continue
|
||||
@@ -434,7 +434,7 @@ func UpdatePullReviewRequest(ctx *context.Context) {
|
||||
ctx.Status(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
ctx.ServerError("GetUserByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -453,7 +453,7 @@ func UpdatePullReviewRequest(ctx *context.Context) {
|
||||
ctx.Status(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
ctx.ServerError("ReviewRequest", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
+24
-32
@@ -207,7 +207,7 @@ func Releases(ctx *context.Context) {
|
||||
RepoID: ctx.Repo.Repository.ID,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("getReleaseInfos", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
for _, rel := range releases {
|
||||
@@ -256,13 +256,13 @@ func TagsList(ctx *context.Context) {
|
||||
|
||||
releases, err := db.Find[repo_model.Release](ctx, opts)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetReleasesByRepoID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
count, err := db.Count[repo_model.Release](ctx, opts)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetReleasesByRepoID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -313,11 +313,11 @@ func SingleRelease(ctx *context.Context) {
|
||||
IncludeTags: true,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("getReleaseInfos", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if len(releases) != 1 {
|
||||
ctx.NotFound(err)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -342,16 +342,12 @@ func SingleRelease(ctx *context.Context) {
|
||||
func LatestRelease(ctx *context.Context) {
|
||||
release, err := repo_model.GetLatestRelease(ctx, ctx.Repo.Repository)
|
||||
if err != nil {
|
||||
if repo_model.IsErrReleaseNotExist(err) {
|
||||
ctx.NotFound(err)
|
||||
return
|
||||
}
|
||||
ctx.ServerError("GetLatestRelease", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := release.LoadAttributes(ctx); err != nil {
|
||||
ctx.ServerError("LoadAttributes", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -363,7 +359,7 @@ func newReleaseCommon(ctx *context.Context) {
|
||||
|
||||
tags, err := repo_model.GetTagNamesByRepoID(ctx, ctx.Repo.Repository.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetTagNamesByRepoID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Tags"] = tags
|
||||
@@ -386,14 +382,14 @@ func NewRelease(ctx *context.Context) {
|
||||
if tagName := ctx.FormString("tag"); tagName != "" {
|
||||
rel, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, tagName)
|
||||
if err != nil && !repo_model.IsErrReleaseNotExist(err) {
|
||||
ctx.ServerError("GetRelease", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
if rel != nil {
|
||||
rel.Repo = ctx.Repo.Repository
|
||||
if err = rel.LoadAttributes(ctx); err != nil {
|
||||
ctx.ServerError("LoadAttributes", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -444,7 +440,7 @@ func NewReleasePost(ctx *context.Context) {
|
||||
// the logic should be done before the form error check to make the tmpl has correct variables
|
||||
rel, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, form.TagName)
|
||||
if err != nil && !repo_model.IsErrReleaseNotExist(err) {
|
||||
ctx.ServerError("GetRelease", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -481,7 +477,7 @@ func NewReleasePost(ctx *context.Context) {
|
||||
case release_service.IsErrProtectedTagName(err):
|
||||
ctx.JSONError(ctx.Tr("repo.release.tag_name_protected"))
|
||||
default:
|
||||
ctx.ServerError("handleTagReleaseError", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -563,15 +559,11 @@ func EditRelease(ctx *context.Context) {
|
||||
tagName := ctx.PathParam("*")
|
||||
rel, err := repo_model.GetRelease(ctx, ctx.Repo.Repository.ID, tagName)
|
||||
if err != nil {
|
||||
if repo_model.IsErrReleaseNotExist(err) {
|
||||
ctx.NotFound(err)
|
||||
} else {
|
||||
ctx.ServerError("GetRelease", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if rel.IsTag {
|
||||
ctx.NotFound(err) // for a pure tag release, don't allow to edit it as a release
|
||||
ctx.NotFound() // for a pure tag release, don't allow to edit it as a release
|
||||
return
|
||||
}
|
||||
|
||||
@@ -586,7 +578,7 @@ func EditRelease(ctx *context.Context) {
|
||||
|
||||
rel.Repo = ctx.Repo.Repository
|
||||
if err := rel.LoadAttributes(ctx); err != nil {
|
||||
ctx.ServerError("LoadAttributes", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
ctx.Data["attachments"] = rel.Attachments
|
||||
@@ -608,7 +600,7 @@ func EditReleasePost(ctx *context.Context) {
|
||||
if repo_model.IsErrReleaseNotExist(err) {
|
||||
ctx.JSONErrorNotFound(err.Error())
|
||||
} else {
|
||||
ctx.ServerError("GetRelease", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -680,7 +672,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(err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
} else {
|
||||
ctx.Flash.Error("DeleteReleaseByID: " + err.Error())
|
||||
redirect()
|
||||
@@ -718,11 +710,11 @@ func ChangeReleaseReaction(ctx *context.Context) {
|
||||
|
||||
rel, err := repo_model.GetReleaseForRepoByID(ctx, ctx.Repo.Repository.ID, ctx.PathParamInt64("id"))
|
||||
if err != nil {
|
||||
ctx.ServerError("GetReleaseForRepoByID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if rel.IsTag || rel.IsDraft {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
rel.Repo = ctx.Repo.Repository
|
||||
@@ -734,26 +726,26 @@ func ChangeReleaseReaction(ctx *context.Context) {
|
||||
ctx.HTTPError(http.StatusForbidden)
|
||||
return
|
||||
} else if err != nil && !errors.Is(err, util.ErrAlreadyExist) {
|
||||
ctx.ServerError("CreateReleaseReaction", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
case "unreact":
|
||||
if err = issues_model.DeleteReleaseReaction(ctx, ctx.Doer.ID, rel.ID, form.Content); err != nil {
|
||||
ctx.ServerError("DeleteReleaseReaction", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
default:
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
reactions, err := issues_model.FindReleaseReactions(ctx, rel.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("FindReleaseReactions", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if _, err = reactions.LoadUsers(ctx, ctx.Repo.Repository); err != nil {
|
||||
ctx.ServerError("LoadUsers", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
renderReactions(ctx, fmt.Sprintf("%s/releases/%d/reactions", ctx.Repo.RepoLink, rel.ID), reactions, release_service.AllowedReleaseReactions())
|
||||
|
||||
@@ -24,17 +24,13 @@ func RenderFile(ctx *context.Context) {
|
||||
blob, err = ctx.Repo.GitRepo.GetBlob(ctx.PathParam("sha"))
|
||||
}
|
||||
if err != nil {
|
||||
if git.IsErrNotExist(err) {
|
||||
ctx.NotFound(err)
|
||||
} else {
|
||||
ctx.ServerError("GetBlobByPath", err)
|
||||
}
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
|
||||
blobReader, err := blob.DataAsync(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("DataAsync", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
defer blobReader.Close()
|
||||
|
||||
+16
-16
@@ -43,14 +43,14 @@ const (
|
||||
// MustBeNotEmpty render when a repo is a empty git dir
|
||||
func MustBeNotEmpty(ctx *context.Context) {
|
||||
if ctx.Repo.Repository.IsEmpty {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
}
|
||||
}
|
||||
|
||||
// MustBeEditable check that repo can be edited
|
||||
func MustBeEditable(ctx *context.Context) {
|
||||
if !ctx.Repo.Repository.CanContentChange() {
|
||||
ctx.NotFound(nil)
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -58,14 +58,14 @@ 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()
|
||||
}
|
||||
}
|
||||
|
||||
func checkContextUser(ctx *context.Context, uid int64) *user_model.User {
|
||||
orgs, err := organization.GetOrgsCanCreateRepoByUserID(ctx, ctx.Doer.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetOrgsCanCreateRepoByUserID", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ func checkContextUser(ctx *context.Context, uid int64) *user_model.User {
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
ctx.ServerError("GetUserByID", fmt.Errorf("[%d]: %w", uid, err))
|
||||
ctx.ServerErrorAuto(fmt.Errorf("[%d]: %w", uid, err))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ func checkContextUser(ctx *context.Context, uid int64) *user_model.User {
|
||||
if !ctx.Doer.IsAdmin {
|
||||
canCreate, err := organization.OrgFromUser(org).CanCreateOrgRepo(ctx, ctx.Doer.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("CanCreateOrgRepo", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return nil
|
||||
} else if !canCreate {
|
||||
ctx.HTTPError(http.StatusForbidden)
|
||||
@@ -164,7 +164,7 @@ func Create(ctx *context.Context) {
|
||||
ctx.HTML(http.StatusOK, tplCreate)
|
||||
}
|
||||
|
||||
func handleCreateError(ctx *context.Context, owner *user_model.User, err error, name string, tpl templates.TplName, form any) {
|
||||
func handleCreateError(ctx *context.Context, owner *user_model.User, err error, tpl templates.TplName, form any) {
|
||||
var errNameReserved db.ErrNameReserved
|
||||
var errNamePatternNotAllowed db.ErrNamePatternNotAllowed
|
||||
switch {
|
||||
@@ -185,7 +185,7 @@ func handleCreateError(ctx *context.Context, owner *user_model.User, err error,
|
||||
ctx.Data["Err_RepoName"] = true
|
||||
ctx.RenderWithErrDeprecated(ctx.Tr("repo.form.name_pattern_not_allowed", errNamePatternNotAllowed.Pattern), tpl, form)
|
||||
default:
|
||||
ctx.ServerError(name, err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ func CreatePost(ctx *context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
handleCreateError(ctx, ctxUser, err, "CreatePost", tplCreate, &form)
|
||||
handleCreateError(ctx, ctxUser, err, tplCreate, &form)
|
||||
}
|
||||
|
||||
func handleRepoActionError(ctx *context.Context, err error) {
|
||||
@@ -286,7 +286,7 @@ func handleRepoActionError(ctx *context.Context, err error) {
|
||||
case errors.Is(err, util.ErrPermissionDenied):
|
||||
ctx.JSONError(ctx.Tr("error.permission_denied"))
|
||||
default:
|
||||
ctx.ServerError("RepoAction:"+ctx.PathParam("action"), err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ func RedirectDownload(ctx *context.Context) {
|
||||
TagNames: tagNames,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("RedirectDownload", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if len(releases) == 1 {
|
||||
@@ -352,7 +352,7 @@ func Download(ctx *context.Context) {
|
||||
} else if errors.Is(err, util.ErrNotExist) {
|
||||
ctx.HTTPError(http.StatusNotFound, err.Error())
|
||||
} else {
|
||||
ctx.ServerError("archiver_service.NewRequest", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -361,7 +361,7 @@ func Download(ctx *context.Context) {
|
||||
if errors.Is(err, util.ErrInvalidArgument) {
|
||||
ctx.HTTPError(http.StatusBadRequest, err.Error())
|
||||
} else {
|
||||
ctx.ServerError("archiver_service.ServeRepoArchive", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -393,12 +393,12 @@ func InitiateDownload(ctx *context.Context) {
|
||||
|
||||
archiver, err := repo_model.GetRepoArchiver(ctx, aReq.Repo.ID, aReq.Type, aReq.CommitID)
|
||||
if err != nil {
|
||||
ctx.ServerError("archiver_service.StartArchive", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
if archiver == nil || archiver.Status != repo_model.ArchiverReady {
|
||||
if err := archiver_service.StartArchive(aReq); err != nil {
|
||||
ctx.ServerError("archiver_service.StartArchive", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -594,7 +594,7 @@ func PrepareBranchList(ctx *context.Context) {
|
||||
}
|
||||
brs, err := git_model.FindBranchNames(ctx, branchOpts)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetBranches", err)
|
||||
ctx.ServerErrorAuto(err)
|
||||
return
|
||||
}
|
||||
// always put default branch on the top if it exists
|
||||
|
||||
Loaded 100 of 167 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user