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

Function TestHandledInDomain

domains/domains_test.go:122–141  ·  view source on GitHub ↗

This test demonstrates how the original domain becomes invisible via HandledInDomain(), and even the original error becomes invisible.

(t *testing.T)

Source from the content-addressed store, hash-verified

120// This test demonstrates how the original domain becomes invisible
121// via HandledInDomain(), and even the original error becomes invisible.
122func TestHandledInDomain(t *testing.T) {
123 origErr := domains.New("hello")
124 t.Logf("origErr: %# v", pretty.Formatter(origErr))
125 origDomain := domains.GetDomain(origErr)
126
127 otherDomain := domains.NamedDomain("woo")
128 err := domains.HandledInDomain(origErr, otherDomain)
129 t.Logf("err: %# v", pretty.Formatter(err))
130
131 tt := testutils.T{T: t}
132
133 // The original domain becomes invisible.
134 tt.Check(domains.NotInDomain(err, origDomain))
135
136 // The cause becomes invisible.
137 tt.Check(!markers.Is(err, origErr))
138
139 // However, the error message is preserved fully.
140 tt.CheckEqual(err.Error(), "hello")
141}
142
143// This test demonstrates that Handled() overrides an error's original
144// domain with the current package's local domain.

Callers

nothing calls this directly

Calls 9

CheckMethod · 0.95
CheckEqualMethod · 0.95
NewFunction · 0.92
GetDomainFunction · 0.92
NamedDomainFunction · 0.92
HandledInDomainFunction · 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…