1
0
Fork 0
forked from forgejo/forgejo

Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551)

Found using
`find . -type f -name '*.go' -print -exec vim {} -c
':%s/fmt\.Errorf(\(.*\)%v\(.*\)err/fmt.Errorf(\1%w\2err/g' -c ':wq' \;`

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
delvh 2022-10-24 21:29:17 +02:00 committed by GitHub
parent 7c11a73833
commit 0ebb45cfe7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
207 changed files with 857 additions and 857 deletions

View file

@ -288,10 +288,10 @@ func CreateOrganization(org *Organization, owner *user_model.User) (err error) {
}
if err = db.Insert(ctx, org); err != nil {
return fmt.Errorf("insert organization: %v", err)
return fmt.Errorf("insert organization: %w", err)
}
if err = user_model.GenerateRandomAvatar(ctx, org.AsUser()); err != nil {
return fmt.Errorf("generate random avatar: %v", err)
return fmt.Errorf("generate random avatar: %w", err)
}
// Add initial creator to organization and owner team.
@ -299,7 +299,7 @@ func CreateOrganization(org *Organization, owner *user_model.User) (err error) {
UID: owner.ID,
OrgID: org.ID,
}); err != nil {
return fmt.Errorf("insert org-user relation: %v", err)
return fmt.Errorf("insert org-user relation: %w", err)
}
// Create default owner team.
@ -313,7 +313,7 @@ func CreateOrganization(org *Organization, owner *user_model.User) (err error) {
CanCreateOrgRepo: true,
}
if err = db.Insert(ctx, t); err != nil {
return fmt.Errorf("insert owner team: %v", err)
return fmt.Errorf("insert owner team: %w", err)
}
// insert units for team
@ -335,7 +335,7 @@ func CreateOrganization(org *Organization, owner *user_model.User) (err error) {
OrgID: org.ID,
TeamID: t.ID,
}); err != nil {
return fmt.Errorf("insert team-user relation: %v", err)
return fmt.Errorf("insert team-user relation: %w", err)
}
return committer.Commit()
@ -372,11 +372,11 @@ func DeleteOrganization(ctx context.Context, org *Organization) error {
&TeamUnit{OrgID: org.ID},
&TeamInvite{OrgID: org.ID},
); err != nil {
return fmt.Errorf("DeleteBeans: %v", err)
return fmt.Errorf("DeleteBeans: %w", err)
}
if _, err := db.GetEngine(ctx).ID(org.ID).Delete(new(user_model.User)); err != nil {
return fmt.Errorf("Delete: %v", err)
return fmt.Errorf("Delete: %w", err)
}
return nil
@ -760,7 +760,7 @@ func (env *accessibleReposEnv) CountRepos() (int64, error) {
Distinct("`repository`.id").
Count(&repo_model.Repository{})
if err != nil {
return 0, fmt.Errorf("count user repositories in organization: %v", err)
return 0, fmt.Errorf("count user repositories in organization: %w", err)
}
return repoCount, nil
}
@ -785,7 +785,7 @@ func (env *accessibleReposEnv) RepoIDs(page, pageSize int) ([]int64, error) {
func (env *accessibleReposEnv) Repos(page, pageSize int) ([]*repo_model.Repository, error) {
repoIDs, err := env.RepoIDs(page, pageSize)
if err != nil {
return nil, fmt.Errorf("GetUserRepositoryIDs: %v", err)
return nil, fmt.Errorf("GetUserRepositoryIDs: %w", err)
}
repos := make([]*repo_model.Repository, 0, len(repoIDs))
@ -814,7 +814,7 @@ func (env *accessibleReposEnv) MirrorRepoIDs() ([]int64, error) {
func (env *accessibleReposEnv) MirrorRepos() ([]*repo_model.Repository, error) {
repoIDs, err := env.MirrorRepoIDs()
if err != nil {
return nil, fmt.Errorf("MirrorRepoIDs: %v", err)
return nil, fmt.Errorf("MirrorRepoIDs: %w", err)
}
repos := make([]*repo_model.Repository, 0, len(repoIDs))