From 0ebb45cfe7606adf021ad359d6fbfcefc54360a5 Mon Sep 17 00:00:00 2001 From: delvh Date: Mon, 24 Oct 2022 21:29:17 +0200 Subject: 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 Co-authored-by: wxiaoguang --- modules/markup/external/external.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'modules/markup/external/external.go') diff --git a/modules/markup/external/external.go b/modules/markup/external/external.go index 23dd45ba0a..0eeb2d70a5 100644 --- a/modules/markup/external/external.go +++ b/modules/markup/external/external.go @@ -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 } -- cgit v1.2.3