| 85 | } |
| 86 | |
| 87 | func TestNATSErrorWrapping(t *testing.T) { |
| 88 | // Test error chain |
| 89 | baseErr := errors.New("connection failed") |
| 90 | natsErr := &NATSError{ |
| 91 | Subject: "test.subject", |
| 92 | Description: "service error: connection failed", |
| 93 | err: baseErr, |
| 94 | } |
| 95 | |
| 96 | // Check that we can find the base error in the chain |
| 97 | if !errors.Is(natsErr, baseErr) { |
| 98 | t.Errorf("errors.Is() should find base error in chain") |
| 99 | } |
| 100 | |
| 101 | // Test error message |
| 102 | expectedMsg := `"test.subject": service error: connection failed` |
| 103 | if natsErr.Error() != expectedMsg { |
| 104 | t.Errorf("Error() = %q, want %q", natsErr.Error(), expectedMsg) |
| 105 | } |
| 106 | } |