Renaming IsErr to ErrorIs

Signed-off-by: Matthias Hanel <mh@synadia.com>
This commit is contained in:
Matthias Hanel
2020-02-25 19:53:09 -05:00
parent b6d5906154
commit 2754968e33
3 changed files with 4 additions and 4 deletions

View File

@@ -261,7 +261,7 @@ func errorsUnwrap(err error) error {
// implements: go 1.13 errors.Is(err, target error) bool
// TODO replace with native code once we no longer support go1.12
func IsErr(err, target error) bool {
func ErrorIs(err, target error) bool {
// this is an outright copy of go 1.13 errors.Is(err, target error) bool
// removed isComparable
if err == nil || target == nil {

View File

@@ -28,7 +28,7 @@ func TestErrCtx(t *testing.T) {
if e == ErrWrongGateway {
t.Fatalf("%v and %v can't be compared this way", e, ErrWrongGateway)
}
if !IsErr(e, ErrWrongGateway) {
if !ErrorIs(e, ErrWrongGateway) {
t.Fatalf("%s and %s ", e, ErrWrongGateway)
}
if UnpackIfErrorCtx(ErrWrongGateway) != ErrWrongGateway.Error() {
@@ -55,7 +55,7 @@ func TestErrCtxWrapped(t *testing.T) {
if e == ErrWrongGateway {
t.Fatalf("%v and %v can't be compared this way", e, ErrWrongGateway)
}
if !IsErr(e, ErrWrongGateway) {
if !ErrorIs(e, ErrWrongGateway) {
t.Fatalf("%s and %s ", e, ErrWrongGateway)
}
if UnpackIfErrorCtx(ErrWrongGateway) != ErrWrongGateway.Error() {

View File

@@ -582,7 +582,7 @@ func TestMaxControlLine(t *testing.T) {
pub := []byte("PUB foo.bar 11\r")
err := c.parse(pub)
if !IsErr(err, ErrMaxControlLine) {
if !ErrorIs(err, ErrMaxControlLine) {
t.Fatalf("Expected an error parsing longer than expected control line")
}
}