diff options
Diffstat (limited to 'routers/web')
-rw-r--r-- | routers/web/auth/auth.go | 2 | ||||
-rw-r--r-- | routers/web/auth/oauth.go | 4 | ||||
-rw-r--r-- | routers/web/repo/lfs.go | 8 | ||||
-rw-r--r-- | routers/web/repo/release.go | 4 | ||||
-rw-r--r-- | routers/web/repo/repo.go | 2 | ||||
-rw-r--r-- | routers/web/repo/setting.go | 6 | ||||
-rw-r--r-- | routers/web/user/home.go | 4 | ||||
-rw-r--r-- | routers/web/user/setting/profile.go | 8 |
8 files changed, 19 insertions, 19 deletions
diff --git a/routers/web/auth/auth.go b/routers/web/auth/auth.go index b48bdb9951..25d70d7c47 100644 --- a/routers/web/auth/auth.go +++ b/routers/web/auth/auth.go @@ -70,7 +70,7 @@ func AutoSignIn(ctx *context.Context) (bool, error) { u, err := user_model.GetUserByName(ctx, uname) if err != nil { if !user_model.IsErrUserNotExist(err) { - return false, fmt.Errorf("GetUserByName: %v", err) + return false, fmt.Errorf("GetUserByName: %w", err) } return false, nil } diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go index 9c929d990e..4fba8d8e8c 100644 --- a/routers/web/auth/oauth.go +++ b/routers/web/auth/oauth.go @@ -303,7 +303,7 @@ func InfoOAuth(ctx *context.Context) { func getOAuthGroupsForUser(user *user_model.User) ([]string, error) { orgs, err := org_model.GetUserOrgsList(user) if err != nil { - return nil, fmt.Errorf("GetUserOrgList: %v", err) + return nil, fmt.Errorf("GetUserOrgList: %w", err) } var groups []string @@ -311,7 +311,7 @@ func getOAuthGroupsForUser(user *user_model.User) ([]string, error) { groups = append(groups, org.Name) teams, err := org.LoadTeams() if err != nil { - return nil, fmt.Errorf("LoadTeams: %v", err) + return nil, fmt.Errorf("LoadTeams: %w", err) } for _, team := range teams { if team.IsMember(user.ID) { diff --git a/routers/web/repo/lfs.go b/routers/web/repo/lfs.go index 41639c4603..67cb6837a5 100644 --- a/routers/web/repo/lfs.go +++ b/routers/web/repo/lfs.go @@ -122,14 +122,14 @@ func LFSLocks(ctx *context.Context) { Shared: true, }); err != nil { log.Error("Failed to clone repository: %s (%v)", ctx.Repo.Repository.FullName(), err) - ctx.ServerError("LFSLocks", fmt.Errorf("failed to clone repository: %s (%v)", ctx.Repo.Repository.FullName(), err)) + ctx.ServerError("LFSLocks", fmt.Errorf("failed to clone repository: %s (%w)", ctx.Repo.Repository.FullName(), err)) return } gitRepo, err := git.OpenRepository(ctx, tmpBasePath) if err != nil { log.Error("Unable to open temporary repository: %s (%v)", tmpBasePath, err) - ctx.ServerError("LFSLocks", fmt.Errorf("failed to open new temporary repository in: %s %v", tmpBasePath, err)) + ctx.ServerError("LFSLocks", fmt.Errorf("failed to open new temporary repository in: %s %w", tmpBasePath, err)) return } defer gitRepo.Close() @@ -142,7 +142,7 @@ func LFSLocks(ctx *context.Context) { if err := gitRepo.ReadTreeToIndex(ctx.Repo.Repository.DefaultBranch); err != nil { log.Error("Unable to read the default branch to the index: %s (%v)", ctx.Repo.Repository.DefaultBranch, err) - ctx.ServerError("LFSLocks", fmt.Errorf("unable to read the default branch to the index: %s (%v)", ctx.Repo.Repository.DefaultBranch, err)) + ctx.ServerError("LFSLocks", fmt.Errorf("unable to read the default branch to the index: %s (%w)", ctx.Repo.Repository.DefaultBranch, err)) return } @@ -542,7 +542,7 @@ func LFSAutoAssociate(ctx *context.Context) { metas[i] = &git_model.LFSMetaObject{} metas[i].Size, err = strconv.ParseInt(oid[idx+1:], 10, 64) if err != nil { - ctx.ServerError("LFSAutoAssociate", fmt.Errorf("illegal oid input: %s %v", oid, err)) + ctx.ServerError("LFSAutoAssociate", fmt.Errorf("illegal oid input: %s %w", oid, err)) return } metas[i].Oid = oid[:idx] diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go index 1e5710fa98..0cb85f3798 100644 --- a/routers/web/repo/release.go +++ b/routers/web/repo/release.go @@ -46,11 +46,11 @@ func calReleaseNumCommitsBehind(repoCtx *context.Repository, release *repo_model if repoCtx.GitRepo.IsBranchExist(release.Target) { commit, err := repoCtx.GitRepo.GetBranchCommit(release.Target) if err != nil { - return fmt.Errorf("GetBranchCommit: %v", err) + return fmt.Errorf("GetBranchCommit: %w", err) } countCache[release.Target], err = commit.CommitsCount() if err != nil { - return fmt.Errorf("CommitsCount: %v", err) + return fmt.Errorf("CommitsCount: %w", err) } } else { // Use NumCommits of the newest release on that target diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go index 974f03f951..3e746d3f05 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -90,7 +90,7 @@ func checkContextUser(ctx *context.Context, uid int64) *user_model.User { } if err != nil { - ctx.ServerError("GetUserByID", fmt.Errorf("[%d]: %v", uid, err)) + ctx.ServerError("GetUserByID", fmt.Errorf("[%d]: %w", uid, err)) return nil } diff --git a/routers/web/repo/setting.go b/routers/web/repo/setting.go index e7abec0d3e..2b5691ce88 100644 --- a/routers/web/repo/setting.go +++ b/routers/web/repo/setting.go @@ -1197,7 +1197,7 @@ func UpdateAvatarSetting(ctx *context.Context, form forms.AvatarForm) error { r, err := form.Avatar.Open() if err != nil { - return fmt.Errorf("Avatar.Open: %v", err) + return fmt.Errorf("Avatar.Open: %w", err) } defer r.Close() @@ -1207,14 +1207,14 @@ func UpdateAvatarSetting(ctx *context.Context, form forms.AvatarForm) error { data, err := io.ReadAll(r) if err != nil { - return fmt.Errorf("io.ReadAll: %v", err) + return fmt.Errorf("io.ReadAll: %w", err) } st := typesniffer.DetectContentType(data) if !(st.IsImage() && !st.IsSvgImage()) { return errors.New(ctx.Tr("settings.uploaded_avatar_not_a_image")) } if err = repo_service.UploadAvatar(ctxRepo, data); err != nil { - return fmt.Errorf("UploadAvatar: %v", err) + return fmt.Errorf("UploadAvatar: %w", err) } return nil } diff --git a/routers/web/user/home.go b/routers/web/user/home.go index 837caedc84..95ec1aa2fa 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -697,11 +697,11 @@ func issueIDsFromSearch(ctx *context.Context, ctxUser *user_model.User, keyword searchRepoIDs, err := issues_model.GetRepoIDsForIssuesOptions(opts, ctxUser) if err != nil { - return nil, fmt.Errorf("GetRepoIDsForIssuesOptions: %v", err) + return nil, fmt.Errorf("GetRepoIDsForIssuesOptions: %w", err) } issueIDsFromSearch, err := issue_indexer.SearchIssuesByKeyword(ctx, searchRepoIDs, keyword) if err != nil { - return nil, fmt.Errorf("SearchIssuesByKeyword: %v", err) + return nil, fmt.Errorf("SearchIssuesByKeyword: %w", err) } return issueIDsFromSearch, nil diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go index c9a7afe982..ba3f5b5080 100644 --- a/routers/web/user/setting/profile.go +++ b/routers/web/user/setting/profile.go @@ -162,7 +162,7 @@ func UpdateAvatarSetting(ctx *context.Context, form *forms.AvatarForm, ctxUser * if form.Avatar != nil && form.Avatar.Filename != "" { fr, err := form.Avatar.Open() if err != nil { - return fmt.Errorf("Avatar.Open: %v", err) + return fmt.Errorf("Avatar.Open: %w", err) } defer fr.Close() @@ -172,7 +172,7 @@ func UpdateAvatarSetting(ctx *context.Context, form *forms.AvatarForm, ctxUser * data, err := io.ReadAll(fr) if err != nil { - return fmt.Errorf("io.ReadAll: %v", err) + return fmt.Errorf("io.ReadAll: %w", err) } st := typesniffer.DetectContentType(data) @@ -180,7 +180,7 @@ func UpdateAvatarSetting(ctx *context.Context, form *forms.AvatarForm, ctxUser * return errors.New(ctx.Tr("settings.uploaded_avatar_not_a_image")) } if err = user_service.UploadAvatar(ctxUser, data); err != nil { - return fmt.Errorf("UploadAvatar: %v", err) + return fmt.Errorf("UploadAvatar: %w", err) } } else if ctxUser.UseCustomAvatar && ctxUser.Avatar == "" { // No avatar is uploaded but setting has been changed to enable, @@ -191,7 +191,7 @@ func UpdateAvatarSetting(ctx *context.Context, form *forms.AvatarForm, ctxUser * } if err := user_model.UpdateUserCols(ctx, ctxUser, "avatar", "avatar_email", "use_custom_avatar"); err != nil { - return fmt.Errorf("UpdateUser: %v", err) + return fmt.Errorf("UpdateUser: %w", err) } return nil |