mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-14 15:56:44 +03:00
Use %w to wrap errors (#1175)
This commit is contained in:
@@ -73,7 +73,7 @@ func testWriter(newWriter NewWriterFunc, newReader func(io.Reader) io.Reader) er
|
||||
|
||||
for i := 0; i < 5; i++ {
|
||||
if err := testWriterReuse(w, dstW, newReader); err != nil {
|
||||
return fmt.Errorf("unexpected error when re-using writer on iteration %d: %s", i, err)
|
||||
return fmt.Errorf("unexpected error when re-using writer on iteration %d: %w", i, err)
|
||||
}
|
||||
dstW = &bytes.Buffer{}
|
||||
w.Reset(dstW)
|
||||
@@ -89,7 +89,7 @@ func testWriterReuse(w Writer, r io.Reader, newReader func(io.Reader) io.Reader)
|
||||
fmt.Fprintf(mw, "foobar %d\n", i)
|
||||
if i%13 == 0 {
|
||||
if err := w.Flush(); err != nil {
|
||||
return fmt.Errorf("error on flush: %s", err)
|
||||
return fmt.Errorf("error on flush: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ func testWriterReuse(w Writer, r io.Reader, newReader func(io.Reader) io.Reader)
|
||||
zr := newReader(r)
|
||||
data, err := ioutil.ReadAll(zr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unexpected error: %s, data=%q", err, data)
|
||||
return fmt.Errorf("unexpected error: %w, data=%q", err, data)
|
||||
}
|
||||
|
||||
wantData := wantW.Bytes()
|
||||
@@ -120,7 +120,7 @@ func testConcurrent(testFunc func() error, concurrency int) error {
|
||||
select {
|
||||
case err := <-ch:
|
||||
if err != nil {
|
||||
return fmt.Errorf("unexpected error on goroutine %d: %s", i, err)
|
||||
return fmt.Errorf("unexpected error on goroutine %d: %w", i, err)
|
||||
}
|
||||
case <-time.After(time.Second):
|
||||
return fmt.Errorf("timeout on goroutine %d", i)
|
||||
|
||||
Reference in New Issue
Block a user