package errors import ( "errors" "testing" "github.com/stretchr/testify/assert" ) func TestContextualError(t *testing.T) { err := errors.New("example wrapped error") cerr := New("example message", err) assert.ErrorIs(t, cerr, err, "Error did not unwrap into expected error") t.Log(cerr.Context) assert.NotEmpty(t, cerr.Context, "Error context should have been successfully created") assert.Contains(t, cerr.Context, "TestContextualError", "Error context should contain function name") assert.Contains(t, cerr.Context, "12", "Error should contain the line number it was created on") }