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:
@@ -5,7 +5,6 @@ package protocol
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
@@ -66,7 +65,7 @@ func readHello(c io.Reader) (HelloResult, error) {
|
||||
}
|
||||
msgSize := binary.BigEndian.Uint16(header[:2])
|
||||
if msgSize > 32767 {
|
||||
return HelloResult{}, fmt.Errorf("hello message too big")
|
||||
return HelloResult{}, errors.New("hello message too big")
|
||||
}
|
||||
buf := make([]byte, msgSize)
|
||||
if _, err := io.ReadFull(c, buf); err != nil {
|
||||
|
||||
@@ -27,7 +27,7 @@ func (a luhnAlphabet) generate(s string) (rune, error) {
|
||||
for i := range s {
|
||||
codepoint := strings.IndexByte(string(a), s[i])
|
||||
if codepoint == -1 {
|
||||
return 0, fmt.Errorf("Digit %q not valid in alphabet %q", s[i], a)
|
||||
return 0, fmt.Errorf("digit %q not valid in alphabet %q", s[i], a)
|
||||
}
|
||||
addend := factor * codepoint
|
||||
if factor == 2 {
|
||||
|
||||
Reference in New Issue
Block a user