aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ancestor/integration_test.go4
-rw-r--r--ancestor/unit_test.go3
-rw-r--r--format/commitgraph/read/read_test.go4
-rw-r--r--format/pack/ingest/ingest_test.go6
-rw-r--r--format/pktline/decoder_invalid_0003_test.go3
-rw-r--r--format/pktline/decoder_rejects_over_maximum_length_test.go3
-rw-r--r--format/pktline/decoder_resync_after_over_wire_max_test.go3
-rw-r--r--format/sideband64k/decoder_invalid_band_test.go3
-rw-r--r--format/sideband64k/decoder_invalid_empty_payload_test.go3
-rw-r--r--format/sideband64k/decoder_malformed_pktline_test.go6
-rw-r--r--format/sideband64k/decoder_resync_after_over_wire_max_test.go3
-rw-r--r--internal/commitquery/oid.go3
-rw-r--r--mergebase/unit_test.go4
-rw-r--r--reachability/integration_test.go4
-rw-r--r--reachability/unit_test.go8
-rw-r--r--reachability/walk_expand_commits_graph.go3
16 files changed, 25 insertions, 38 deletions
diff --git a/ancestor/integration_test.go b/ancestor/integration_test.go
index d13c86ed..fa630f57 100644
--- a/ancestor/integration_test.go
+++ b/ancestor/integration_test.go
@@ -112,8 +112,8 @@ func TestIsMissingObject(t *testing.T) {
t.Fatal("expected error")
}
- var missing *giterrors.ObjectMissingError
- if !errors.As(err, &missing) {
+ missing, ok := errors.AsType[*giterrors.ObjectMissingError](err)
+ if !ok {
t.Fatalf("expected ObjectMissingError, got %T (%v)", err, err)
}
diff --git a/ancestor/unit_test.go b/ancestor/unit_test.go
index 827aeb8f..b6ca7b58 100644
--- a/ancestor/unit_test.go
+++ b/ancestor/unit_test.go
@@ -110,8 +110,7 @@ func TestIsRejectsNonCommitAfterPeel(t *testing.T) {
t.Fatal("expected error")
}
- var typeErr *giterrors.ObjectTypeError
- if !errors.As(err, &typeErr) {
+ if _, ok := errors.AsType[*giterrors.ObjectTypeError](err); !ok {
t.Fatalf("expected ObjectTypeError, got %T (%v)", err, err)
}
})
diff --git a/format/commitgraph/read/read_test.go b/format/commitgraph/read/read_test.go
index 234ece6b..bd2abd3d 100644
--- a/format/commitgraph/read/read_test.go
+++ b/format/commitgraph/read/read_test.go
@@ -159,8 +159,8 @@ func TestBloomUnavailableWithoutChangedPaths(t *testing.T) {
t.Fatal("BloomFilterAt() error = nil, want BloomUnavailableError")
}
- var unavailable *read.BloomUnavailableError
- if !errors.As(err, &unavailable) {
+ unavailable, ok := errors.AsType[*read.BloomUnavailableError](err)
+ if !ok {
t.Fatalf("BloomFilterAt() error type = %T, want *BloomUnavailableError", err)
}
diff --git a/format/pack/ingest/ingest_test.go b/format/pack/ingest/ingest_test.go
index 8f50b3d1..a40f9ad9 100644
--- a/format/pack/ingest/ingest_test.go
+++ b/format/pack/ingest/ingest_test.go
@@ -211,8 +211,7 @@ func TestIngestThinPackWithoutFixReturnsUnresolved(t *testing.T) {
t.Fatal("Ingest error = nil, want error")
}
- var unresolved *ingest.ThinPackUnresolvedError
- if !errors.As(err, &unresolved) {
+ if _, ok := errors.AsType[*ingest.ThinPackUnresolvedError](err); !ok {
t.Fatalf("Ingest error type = %T (%v), want *ThinPackUnresolvedError", err, err)
}
@@ -282,8 +281,7 @@ func TestIngestPackTrailerMismatch(t *testing.T) {
t.Fatal("Ingest error = nil, want error")
}
- var mismatch *ingest.PackTrailerMismatchError
- if !errors.As(err, &mismatch) {
+ if _, ok := errors.AsType[*ingest.PackTrailerMismatchError](err); !ok {
t.Fatalf("Ingest error type = %T (%v), want *PackTrailerMismatchError", err, err)
}
diff --git a/format/pktline/decoder_invalid_0003_test.go b/format/pktline/decoder_invalid_0003_test.go
index adda99a3..3a93633c 100644
--- a/format/pktline/decoder_invalid_0003_test.go
+++ b/format/pktline/decoder_invalid_0003_test.go
@@ -14,8 +14,7 @@ func TestDecoderInvalid0003(t *testing.T) {
dec := pktline.NewDecoder(strings.NewReader("0003"), pktline.ReadOptions{})
_, err := dec.ReadFrame()
- var pe *pktline.ProtocolError
- if !errors.As(err, &pe) {
+ if _, ok := errors.AsType[*pktline.ProtocolError](err); !ok {
t.Fatalf("got err %v, want ProtocolError", err)
}
}
diff --git a/format/pktline/decoder_rejects_over_maximum_length_test.go b/format/pktline/decoder_rejects_over_maximum_length_test.go
index b6059446..8d897a55 100644
--- a/format/pktline/decoder_rejects_over_maximum_length_test.go
+++ b/format/pktline/decoder_rejects_over_maximum_length_test.go
@@ -16,8 +16,7 @@ func TestDecoderRejectsOverMaximumLength(t *testing.T) {
_, err := dec.ReadFrame()
- var pe *pktline.ProtocolError
- if !errors.As(err, &pe) {
+ if _, ok := errors.AsType[*pktline.ProtocolError](err); !ok {
t.Fatalf("got err %v, want ProtocolError", err)
}
}
diff --git a/format/pktline/decoder_resync_after_over_wire_max_test.go b/format/pktline/decoder_resync_after_over_wire_max_test.go
index 8f692f2d..29a3440f 100644
--- a/format/pktline/decoder_resync_after_over_wire_max_test.go
+++ b/format/pktline/decoder_resync_after_over_wire_max_test.go
@@ -22,8 +22,7 @@ func TestDecoderResyncAfterOverWireMax(t *testing.T) {
_, err := dec.ReadFrame()
- var pe *pktline.ProtocolError
- if !errors.As(err, &pe) {
+ if _, ok := errors.AsType[*pktline.ProtocolError](err); !ok {
t.Fatalf("got err %v, want ProtocolError", err)
}
diff --git a/format/sideband64k/decoder_invalid_band_test.go b/format/sideband64k/decoder_invalid_band_test.go
index 5a58640c..12c53891 100644
--- a/format/sideband64k/decoder_invalid_band_test.go
+++ b/format/sideband64k/decoder_invalid_band_test.go
@@ -14,8 +14,7 @@ func TestDecoderInvalidBand(t *testing.T) {
dec := sideband64k.NewDecoder(strings.NewReader("0005\x04"), sideband64k.ReadOptions{})
_, err := dec.ReadFrame()
- var pe *sideband64k.ProtocolError
- if !errors.As(err, &pe) {
+ if _, ok := errors.AsType[*sideband64k.ProtocolError](err); !ok {
t.Fatalf("got err %v, want ProtocolError", err)
}
}
diff --git a/format/sideband64k/decoder_invalid_empty_payload_test.go b/format/sideband64k/decoder_invalid_empty_payload_test.go
index 679e28d3..eb52ad6a 100644
--- a/format/sideband64k/decoder_invalid_empty_payload_test.go
+++ b/format/sideband64k/decoder_invalid_empty_payload_test.go
@@ -14,8 +14,7 @@ func TestDecoderInvalidEmptyPayload(t *testing.T) {
dec := sideband64k.NewDecoder(strings.NewReader("0004"), sideband64k.ReadOptions{})
_, err := dec.ReadFrame()
- var pe *sideband64k.ProtocolError
- if !errors.As(err, &pe) {
+ if _, ok := errors.AsType[*sideband64k.ProtocolError](err); !ok {
t.Fatalf("got err %v, want ProtocolError", err)
}
}
diff --git a/format/sideband64k/decoder_malformed_pktline_test.go b/format/sideband64k/decoder_malformed_pktline_test.go
index ffa746ca..54ea6ffb 100644
--- a/format/sideband64k/decoder_malformed_pktline_test.go
+++ b/format/sideband64k/decoder_malformed_pktline_test.go
@@ -15,8 +15,7 @@ func TestDecoderInvalid0003(t *testing.T) {
dec := sideband64k.NewDecoder(strings.NewReader("0003"), sideband64k.ReadOptions{})
_, err := dec.ReadFrame()
- var pe *pktline.ProtocolError
- if !errors.As(err, &pe) {
+ if _, ok := errors.AsType[*pktline.ProtocolError](err); !ok {
t.Fatalf("got err %v, want pktline.ProtocolError", err)
}
}
@@ -27,8 +26,7 @@ func TestDecoderRejectsOverMaximumLength(t *testing.T) {
dec := sideband64k.NewDecoder(strings.NewReader("fffe"), sideband64k.ReadOptions{})
_, err := dec.ReadFrame()
- var pe *pktline.ProtocolError
- if !errors.As(err, &pe) {
+ if _, ok := errors.AsType[*pktline.ProtocolError](err); !ok {
t.Fatalf("got err %v, want pktline.ProtocolError", err)
}
}
diff --git a/format/sideband64k/decoder_resync_after_over_wire_max_test.go b/format/sideband64k/decoder_resync_after_over_wire_max_test.go
index 09a8c459..c790cd6f 100644
--- a/format/sideband64k/decoder_resync_after_over_wire_max_test.go
+++ b/format/sideband64k/decoder_resync_after_over_wire_max_test.go
@@ -22,8 +22,7 @@ func TestDecoderResyncAfterOverWireMax(t *testing.T) {
_, err := dec.ReadFrame()
- var pe *pktline.ProtocolError
- if !errors.As(err, &pe) {
+ if _, ok := errors.AsType[*pktline.ProtocolError](err); !ok {
t.Fatalf("got err %v, want pktline.ProtocolError", err)
}
diff --git a/internal/commitquery/oid.go b/internal/commitquery/oid.go
index 7ba05eb5..ab40f96e 100644
--- a/internal/commitquery/oid.go
+++ b/internal/commitquery/oid.go
@@ -53,8 +53,7 @@ func (ctx *Context) loadByOID(idx NodeIndex) error {
if ctx.graph != nil {
pos, err := ctx.graph.Lookup(id)
if err != nil {
- var notFound *commitgraphread.NotFoundError
- if !stderrors.As(err, &notFound) {
+ if _, ok := stderrors.AsType[*commitgraphread.NotFoundError](err); !ok {
return err
}
} else {
diff --git a/mergebase/unit_test.go b/mergebase/unit_test.go
index 55c7c9ae..7fa23df2 100644
--- a/mergebase/unit_test.go
+++ b/mergebase/unit_test.go
@@ -288,8 +288,8 @@ func TestQueryRejectsNonCommitAfterPeel(t *testing.T) {
t.Fatal("expected error")
}
- var typeErr *giterrors.ObjectTypeError
- if !errors.As(err, &typeErr) {
+ typeErr, ok := errors.AsType[*giterrors.ObjectTypeError](err)
+ if !ok {
t.Fatalf("expected ObjectTypeError, got %T (%v)", err, err)
}
diff --git a/reachability/integration_test.go b/reachability/integration_test.go
index 6b043d92..feda699b 100644
--- a/reachability/integration_test.go
+++ b/reachability/integration_test.go
@@ -187,8 +187,8 @@ func TestCheckConnectedMissingObject(t *testing.T) {
t.Fatal("expected error")
}
- var missing *giterrors.ObjectMissingError
- if !errors.As(err, &missing) {
+ missing, ok := errors.AsType[*giterrors.ObjectMissingError](err)
+ if !ok {
t.Fatalf("expected ObjectMissingError, got %T (%v)", err, err)
}
diff --git a/reachability/unit_test.go b/reachability/unit_test.go
index dea6d38b..1a2f4773 100644
--- a/reachability/unit_test.go
+++ b/reachability/unit_test.go
@@ -164,8 +164,8 @@ func TestWalkDomainCommitsRejectsNonCommitRootAfterPeel(t *testing.T) {
t.Fatal("expected error")
}
- var typeErr *giterrors.ObjectTypeError
- if !errors.As(err, &typeErr) {
+ typeErr, ok := errors.AsType[*giterrors.ObjectTypeError](err)
+ if !ok {
t.Fatalf("expected ObjectTypeError, got %T (%v)", err, err)
}
@@ -280,8 +280,8 @@ func TestCheckConnectedReturnsConcreteMissingObject(t *testing.T) {
t.Fatal("expected error")
}
- var missing *giterrors.ObjectMissingError
- if !errors.As(err, &missing) {
+ missing, ok := errors.AsType[*giterrors.ObjectMissingError](err)
+ if !ok {
t.Fatalf("expected ObjectMissingError, got %T (%v)", err, err)
}
diff --git a/reachability/walk_expand_commits_graph.go b/reachability/walk_expand_commits_graph.go
index 90e52112..9602f35c 100644
--- a/reachability/walk_expand_commits_graph.go
+++ b/reachability/walk_expand_commits_graph.go
@@ -11,8 +11,7 @@ import (
func (walk *Walk) expandCommitsFromGraph(id objectid.ObjectID) ([]walkItem, bool, error) {
pos, err := walk.reachability.graph.Lookup(id)
if err != nil {
- var notFound *commitgraphread.NotFoundError
- if errors.As(err, &notFound) {
+ if _, ok := errors.AsType[*commitgraphread.NotFoundError](err); ok {
return nil, false, nil
}