From 86d1943f58b6bc6fb2d653ca039e961a0a1a210c Mon Sep 17 00:00:00 2001 From: Christian Gregg Date: Sat, 4 Sep 2021 19:32:46 +0100 Subject: [PATCH] Wrapped errors correctly with %w directive --- cmd/slugcmplr/test_helper.go | 8 ++++---- compile.go | 4 ++-- prepare.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/slugcmplr/test_helper.go b/cmd/slugcmplr/test_helper.go index 2d530ba1..77487d39 100644 --- a/cmd/slugcmplr/test_helper.go +++ b/cmd/slugcmplr/test_helper.go @@ -92,7 +92,7 @@ func setupApp(t *testing.T, h *heroku.Service, fixture string) (string, string, tarball, err := slugcmplr.Targz(dir, tmp.Name()) if err != nil { - return "", "", fmt.Errorf("failed tarring directory: %v", err) + return "", "", fmt.Errorf("failed tarring directory: %w", err) } src, err := h.SourceCreate(context.Background()) @@ -106,7 +106,7 @@ func setupApp(t *testing.T, h *heroku.Service, fixture string) (string, string, src.SourceBlob.PutURL, tarball.Path, ); err != nil { - return "", "", fmt.Errorf("failed to upload test app: %v", err) + return "", "", fmt.Errorf("failed to upload test app: %w", err) } app, err := h.AppSetupCreate(context.Background(), heroku.AppSetupCreateOpts{ @@ -120,7 +120,7 @@ func setupApp(t *testing.T, h *heroku.Service, fixture string) (string, string, }, }) if err != nil { - return "", "", fmt.Errorf("failed to create application: %v", err) + return "", "", fmt.Errorf("failed to create application: %w", err) } t.Logf("created app for %v (%v)", fixture, app.App.Name) @@ -148,7 +148,7 @@ func waitForBuild(t *testing.T, h *heroku.Service, app *heroku.AppSetup) (*herok info, err := h.AppSetupInfo(context.Background(), id) if err != nil { - return nil, fmt.Errorf("(%v) error fetching app info: %v", name, err) + return nil, fmt.Errorf("(%v) error fetching app info: %w", name, err) } t.Logf("(%v) status: %v", name, info.Status) diff --git a/compile.go b/compile.go index 760fbc7c..fe0dd8fa 100644 --- a/compile.go +++ b/compile.go @@ -65,7 +65,7 @@ func (c *CompileCmd) Execute(ctx context.Context, out Outputter) (*CompileResult pf, err := os.Open(filepath.Join(c.BuildDir, buildpack.AppDir, "Procfile")) if err != nil { - return nil, fmt.Errorf("error opening Procfile: %v", err) + return nil, fmt.Errorf("error opening Procfile: %w", err) } defer pf.Close() // nolint:errcheck @@ -79,7 +79,7 @@ func (c *CompileCmd) Execute(ctx context.Context, out Outputter) (*CompileResult filepath.Join(c.BuildDir, "app.tgz"), ) if err != nil { - return nil, fmt.Errorf("error creating tarball: %v", err) + return nil, fmt.Errorf("error creating tarball: %w", err) } return &CompileResult{ diff --git a/prepare.go b/prepare.go index 749b231d..0ef4b7bb 100644 --- a/prepare.go +++ b/prepare.go @@ -68,7 +68,7 @@ func (p *PrepareCmd) Execute(ctx context.Context, out Outputter) (*PrepareResult // exists. ignore, err := slugignore.ForDirectory(p.SourceDir) if err != nil { - return nil, fmt.Errorf("failed to read .slugignore: %v", err) + return nil, fmt.Errorf("failed to read .slugignore: %w", err) } if err := copy.Copy(p.SourceDir, appDir, copy.Options{