diff options
author | delvh <leon@kske.dev> | 2022-10-24 21:29:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-24 20:29:17 +0100 |
commit | 0ebb45cfe7606adf021ad359d6fbfcefc54360a5 (patch) | |
tree | 541b75d083213e93bbbfadbdc5d560c739543903 /models/organization | |
parent | 7c11a73833f3aa9783015e5e13871d3c298d3ef6 (diff) | |
download | gitea-0ebb45cfe7606adf021ad359d6fbfcefc54360a5.tar.gz gitea-0ebb45cfe7606adf021ad359d6fbfcefc54360a5.zip |
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>
Diffstat (limited to 'models/organization')
-rw-r--r-- | models/organization/org.go | 20 | ||||
-rw-r--r-- | models/organization/org_user.go | 2 |
2 files changed, 11 insertions, 11 deletions
diff --git a/models/organization/org.go b/models/organization/org.go index 58b58e6732..993ca3f10d 100644 --- a/models/organization/org.go +++ b/models/organization/org.go @@ -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)) diff --git a/models/organization/org_user.go b/models/organization/org_user.go index a7bc8f7d4c..7a5d17a75a 100644 --- a/models/organization/org_user.go +++ b/models/organization/org_user.go @@ -118,7 +118,7 @@ func loadOrganizationOwners(ctx context.Context, users user_model.UserList, orgI And("team_id=?", ownerTeam.ID). Find(&ownerMaps) if err != nil { - return nil, fmt.Errorf("find team users: %v", err) + return nil, fmt.Errorf("find team users: %w", err) } return ownerMaps, nil } |