This test demonstrates how the original domain becomes invisible via HandledInDomain(), and even the original error becomes invisible.
(t *testing.T)
| 120 | // This test demonstrates how the original domain becomes invisible |
| 121 | // via HandledInDomain(), and even the original error becomes invisible. |
| 122 | func 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. |
nothing calls this directly
no test coverage detected
searching dependent graphs…