This test demonstrates how the original domain becomes invisible via WithDomain(), but the original error remains visible as cause.
(t *testing.T)
| 97 | // This test demonstrates how the original domain becomes invisible |
| 98 | // via WithDomain(), but the original error remains visible as cause. |
| 99 | func 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. |
nothing calls this directly
no test coverage detected
searching dependent graphs…