From 9e0ec96f312042f6d2108a0316af07703d99907c Mon Sep 17 00:00:00 2001 From: sashayakovtseva Date: Mon, 18 Jan 2021 15:25:07 +0300 Subject: [PATCH 1/2] Wrap errors with go 1.13 %w verb --- browser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser.go b/browser.go index 42b6818c..b6eaa23a 100644 --- a/browser.go +++ b/browser.go @@ -112,7 +112,7 @@ func NewBrowser(ctx context.Context, urlstr string, opts ...BrowserOption) (*Bro urlstr = forceIP(urlstr) b.conn, err = DialContext(dialCtx, urlstr, WithConnDebugf(b.dbgf)) if err != nil { - return nil, fmt.Errorf("could not dial %q: %v", urlstr, err) + return nil, fmt.Errorf("could not dial %q: %w", urlstr, err) } go b.run(ctx) From 7c98c9d47ca243e4f7fa4473ad58ea818e581599 Mon Sep 17 00:00:00 2001 From: sashayakovtseva Date: Thu, 29 Apr 2021 17:46:07 +0300 Subject: [PATCH 2/2] Wrap some other errors with %w --- chromedp.go | 2 +- query.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chromedp.go b/chromedp.go index 277a68ac..d02b3d52 100644 --- a/chromedp.go +++ b/chromedp.go @@ -386,7 +386,7 @@ func (c *Context) attachTarget(ctx context.Context, targetID target.ID) error { for _, action := range actions { if err := action.Do(cdp.WithExecutor(ctx, c.Target)); err != nil { - return fmt.Errorf("unable to execute %T: %v", action, err) + return fmt.Errorf("unable to execute %T: %w", action, err) } } return nil diff --git a/query.go b/query.go index 01c1c19b..939c1d7e 100644 --- a/query.go +++ b/query.go @@ -934,7 +934,7 @@ func JavascriptAttribute(sel interface{}, name string, res interface{}, opts ... if err := evalInCtx(ctx, execCtx, snippet(attributeJS, cashX(true), sel, nodes[0], name), res, ); err != nil { - return fmt.Errorf("could not retrieve attribute %q: %v", name, err) + return fmt.Errorf("could not retrieve attribute %q: %w", name, err) } return nil }, opts...)