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:
@@ -3,7 +3,7 @@
|
||||
package protocol
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"errors"
|
||||
"io"
|
||||
)
|
||||
|
||||
@@ -53,7 +53,7 @@ func WriteMessage(w io.Writer, message interface{}) error {
|
||||
payload, err = msg.MarshalXDR()
|
||||
header.messageType = messageTypeRelayFull
|
||||
default:
|
||||
err = fmt.Errorf("Unknown message type")
|
||||
err = errors.New("unknown message type")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -84,7 +84,7 @@ func ReadMessage(r io.Reader) (interface{}, error) {
|
||||
}
|
||||
|
||||
if header.magic != magic {
|
||||
return nil, fmt.Errorf("magic mismatch")
|
||||
return nil, errors.New("magic mismatch")
|
||||
}
|
||||
|
||||
buf = make([]byte, int(header.messageLength))
|
||||
@@ -127,5 +127,5 @@ func ReadMessage(r io.Reader) (interface{}, error) {
|
||||
return msg, err
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("Unknown message type")
|
||||
return nil, errors.New("unknown message type")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user