all: Tweak error creation (#6391)
- In the few places where we wrap errors, use the new Go 1.13 "%w" construction instead of %s or %v. - Where we create errors with constant strings, consistently use errors.New and not fmt.Errorf. - Remove capitalization from errors in the few places where we had that.
This commit is contained in:
+1
-1
@@ -536,7 +536,7 @@ func (w *walker) handleError(ctx context.Context, context, path string, err erro
|
||||
l.Infof("Scanner (folder %s, item %q): %s: %v", w.Folder, path, context, err)
|
||||
select {
|
||||
case finishedChan <- ScanResult{
|
||||
Err: fmt.Errorf("%s: %s", context, err.Error()),
|
||||
Err: fmt.Errorf("%s: %w", context, err),
|
||||
Path: path,
|
||||
}:
|
||||
case <-ctx.Done():
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
@@ -836,7 +837,7 @@ func verify(r io.Reader, blocksize int, blocks []protocol.BlockInfo) error {
|
||||
bs := make([]byte, 1)
|
||||
n, err := r.Read(bs)
|
||||
if n != 0 || err != io.EOF {
|
||||
return fmt.Errorf("file continues past end of blocks")
|
||||
return errors.New("file continues past end of blocks")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user