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

@ -90,7 +90,7 @@ func (p *Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.
// write to temp file
f, err := os.CreateTemp("", "gitea_input")
if err != nil {
return fmt.Errorf("%s create temp file when rendering %s failed: %v", p.Name(), p.Command, err)
return fmt.Errorf("%s create temp file when rendering %s failed: %w", p.Name(), p.Command, err)
}
tmpPath := f.Name()
defer func() {
@ -102,12 +102,12 @@ func (p *Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.
_, err = io.Copy(f, input)
if err != nil {
f.Close()
return fmt.Errorf("%s write data to temp file when rendering %s failed: %v", p.Name(), p.Command, err)
return fmt.Errorf("%s write data to temp file when rendering %s failed: %w", p.Name(), p.Command, err)
}
err = f.Close()
if err != nil {
return fmt.Errorf("%s close temp file when rendering %s failed: %v", p.Name(), p.Command, err)
return fmt.Errorf("%s close temp file when rendering %s failed: %w", p.Name(), p.Command, err)
}
args = append(args, f.Name())
}
@ -137,7 +137,7 @@ func (p *Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.
process.SetSysProcAttribute(cmd)
if err := cmd.Run(); err != nil {
return fmt.Errorf("%s render run command %s %v failed: %v", p.Name(), commands[0], args, err)
return fmt.Errorf("%s render run command %s %v failed: %w", p.Name(), commands[0], args, err)
}
return nil
}