MCPcopy
hub / github.com/nats-io/nats.go / TestNATSErrorWrapping

Function TestNATSErrorWrapping

micro/error_test.go:87–106  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

85}
86
87func 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}

Callers

nothing calls this directly

Calls 3

ErrorMethod · 0.95
ErrorfMethod · 0.80
IsMethod · 0.45

Tested by

no test coverage detected