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:
@ -26,7 +26,7 @@ func getPublicKeyFromResponse(b []byte, keyID *url.URL) (p crypto.PublicKey, err
|
||||
person := ap.PersonNew(ap.IRI(keyID.String()))
|
||||
err = person.UnmarshalJSON(b)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("ActivityStreams type cannot be converted to one known to have publicKey property: %v", err)
|
||||
err = fmt.Errorf("ActivityStreams type cannot be converted to one known to have publicKey property: %w", err)
|
||||
return
|
||||
}
|
||||
pubKey := person.PublicKey
|
||||
|
@ -59,6 +59,6 @@ func SigningKey(ctx *context.APIContext) {
|
||||
}
|
||||
_, err = ctx.Write([]byte(content))
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "gpg export", fmt.Errorf("Error writing key content %v", err))
|
||||
ctx.Error(http.StatusInternalServerError, "gpg export", fmt.Errorf("Error writing key content %w", err))
|
||||
}
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ func HandleCheckKeyStringError(ctx *context.APIContext, err error) {
|
||||
} else if asymkey_model.IsErrKeyUnableVerify(err) {
|
||||
ctx.Error(http.StatusUnprocessableEntity, "", "Unable to verify key content")
|
||||
} else {
|
||||
ctx.Error(http.StatusUnprocessableEntity, "", fmt.Errorf("Invalid key content: %v", err))
|
||||
ctx.Error(http.StatusUnprocessableEntity, "", fmt.Errorf("Invalid key content: %w", err))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ func getCommitStatuses(ctx *context.APIContext, sha string) {
|
||||
State: ctx.FormTrim("state"),
|
||||
})
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "GetCommitStatuses", fmt.Errorf("GetCommitStatuses[%s, %s, %d]: %v", repo.FullName(), sha, ctx.FormInt("page"), err))
|
||||
ctx.Error(http.StatusInternalServerError, "GetCommitStatuses", fmt.Errorf("GetCommitStatuses[%s, %s, %d]: %w", repo.FullName(), sha, ctx.FormInt("page"), err))
|
||||
return
|
||||
}
|
||||
|
||||
@ -255,7 +255,7 @@ func GetCombinedCommitStatusByRef(ctx *context.APIContext) {
|
||||
|
||||
statuses, count, err := git_model.GetLatestCommitStatus(ctx, repo.ID, sha, utils.GetListOptions(ctx))
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "GetLatestCommitStatus", fmt.Errorf("GetLatestCommitStatus[%s, %s]: %v", repo.FullName(), sha, err))
|
||||
ctx.Error(http.StatusInternalServerError, "GetLatestCommitStatus", fmt.Errorf("GetLatestCommitStatus[%s, %s]: %w", repo.FullName(), sha, err))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ func CreateTag(ctx *context.APIContext) {
|
||||
|
||||
commit, err := ctx.Repo.GitRepo.GetCommit(form.Target)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusNotFound, "target not found", fmt.Errorf("target not found: %v", err))
|
||||
ctx.Error(http.StatusNotFound, "target not found", fmt.Errorf("target not found: %w", err))
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user