MCPcopy Create free account
hub / github.com/cockroachdb/errors / TestWithDomain

Function TestWithDomain

domains/domains_test.go:99–118  ·  view source on GitHub ↗

This test demonstrates how the original domain becomes invisible via WithDomain(), but the original error remains visible as cause.

(t *testing.T)

Source from the content-addressed store, hash-verified

97// This test demonstrates how the original domain becomes invisible
98// via WithDomain(), but the original error remains visible as cause.
99func TestWithDomain(t *testing.T) {
100 origErr := domains.New("hello")
101 t.Logf("origErr: %# v", pretty.Formatter(origErr))
102 origDomain := domains.GetDomain(origErr)
103
104 otherDomain := domains.NamedDomain("woo")
105 err := domains.WithDomain(origErr, otherDomain)
106 t.Logf("err: %# v", pretty.Formatter(err))
107
108 tt := testutils.T{T: t}
109
110 // The original domain becomes invisible.
111 tt.Check(domains.NotInDomain(err, origDomain))
112
113 // The cause remains visible.
114 tt.Check(markers.Is(err, origErr))
115
116 // Moreover, the error message is preserved fully.
117 tt.CheckEqual(err.Error(), "hello")
118}
119
120// This test demonstrates how the original domain becomes invisible
121// via HandledInDomain(), and even the original error becomes invisible.

Callers

nothing calls this directly

Calls 9

CheckMethod · 0.95
CheckEqualMethod · 0.95
NewFunction · 0.92
GetDomainFunction · 0.92
NamedDomainFunction · 0.92
WithDomainFunction · 0.92
NotInDomainFunction · 0.92
IsFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…