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:
parent
7c11a73833
commit
0ebb45cfe7
207 changed files with 857 additions and 857 deletions
|
@ -74,12 +74,12 @@ func DeleteRepository(doer *user_model.User, uid, repoID int64) error {
|
|||
// Delete Deploy Keys
|
||||
deployKeys, err := asymkey_model.ListDeployKeys(ctx, &asymkey_model.ListDeployKeysOptions{RepoID: repoID})
|
||||
if err != nil {
|
||||
return fmt.Errorf("listDeployKeys: %v", err)
|
||||
return fmt.Errorf("listDeployKeys: %w", err)
|
||||
}
|
||||
needRewriteKeysFile := len(deployKeys) > 0
|
||||
for _, dKey := range deployKeys {
|
||||
if err := DeleteDeployKey(ctx, doer, dKey.ID); err != nil {
|
||||
return fmt.Errorf("deleteDeployKeys: %v", err)
|
||||
return fmt.Errorf("deleteDeployKeys: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ func DeleteRepository(doer *user_model.User, uid, repoID int64) error {
|
|||
&repo_model.Watch{RepoID: repoID},
|
||||
&webhook.Webhook{RepoID: repoID},
|
||||
); err != nil {
|
||||
return fmt.Errorf("deleteBeans: %v", err)
|
||||
return fmt.Errorf("deleteBeans: %w", err)
|
||||
}
|
||||
|
||||
// Delete Labels and related objects
|
||||
|
@ -178,7 +178,7 @@ func DeleteRepository(doer *user_model.User, uid, repoID int64) error {
|
|||
|
||||
if repo.IsFork {
|
||||
if _, err := db.Exec(ctx, "UPDATE `repository` SET num_forks=num_forks-1 WHERE id=?", repo.ForkID); err != nil {
|
||||
return fmt.Errorf("decrease fork count: %v", err)
|
||||
return fmt.Errorf("decrease fork count: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ func DeleteRepository(doer *user_model.User, uid, repoID int64) error {
|
|||
}
|
||||
|
||||
if err := project_model.DeleteProjectByRepoIDCtx(ctx, repoID); err != nil {
|
||||
return fmt.Errorf("unable to delete projects for repo[%d]: %v", repoID, err)
|
||||
return fmt.Errorf("unable to delete projects for repo[%d]: %w", repoID, err)
|
||||
}
|
||||
|
||||
// Remove LFS objects
|
||||
|
@ -310,7 +310,7 @@ func DeleteRepository(doer *user_model.User, uid, repoID int64) error {
|
|||
|
||||
if len(repo.Avatar) > 0 {
|
||||
if err := storage.RepoAvatars.Delete(repo.CustomAvatarRelativePath()); err != nil {
|
||||
return fmt.Errorf("Failed to remove %s: %v", repo.Avatar, err)
|
||||
return fmt.Errorf("Failed to remove %s: %w", repo.Avatar, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -619,18 +619,18 @@ func DeleteDeployKey(ctx context.Context, doer *user_model.User, id int64) error
|
|||
if asymkey_model.IsErrDeployKeyNotExist(err) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("GetDeployKeyByID: %v", err)
|
||||
return fmt.Errorf("GetDeployKeyByID: %w", err)
|
||||
}
|
||||
|
||||
// Check if user has access to delete this key.
|
||||
if !doer.IsAdmin {
|
||||
repo, err := repo_model.GetRepositoryByIDCtx(ctx, key.RepoID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("GetRepositoryByID: %v", err)
|
||||
return fmt.Errorf("GetRepositoryByID: %w", err)
|
||||
}
|
||||
has, err := access_model.IsUserRepoAdmin(ctx, repo, doer)
|
||||
if err != nil {
|
||||
return fmt.Errorf("GetUserRepoPermission: %v", err)
|
||||
return fmt.Errorf("GetUserRepoPermission: %w", err)
|
||||
} else if !has {
|
||||
return asymkey_model.ErrKeyAccessDenied{
|
||||
UserID: doer.ID,
|
||||
|
@ -643,7 +643,7 @@ func DeleteDeployKey(ctx context.Context, doer *user_model.User, id int64) error
|
|||
if _, err := db.DeleteByBean(ctx, &asymkey_model.DeployKey{
|
||||
ID: key.ID,
|
||||
}); err != nil {
|
||||
return fmt.Errorf("delete deploy key [%d]: %v", key.ID, err)
|
||||
return fmt.Errorf("delete deploy key [%d]: %w", key.ID, err)
|
||||
}
|
||||
|
||||
// Check if this is the last reference to same key content.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue