@@ -26,7 +26,6 @@ import (
26
26
"io"
27
27
"testing"
28
28
29
- richErrors "github.com/pkg/errors"
30
29
"github.com/stretchr/testify/assert"
31
30
32
31
"go.uber.org/multierr"
@@ -113,34 +112,28 @@ func TestErrorEncoding(t *testing.T) {
113
112
},
114
113
{
115
114
k : "k" ,
116
- iface : richErrors . WithMessage ( errors .New ("egad" ), "failed" ),
115
+ iface : fmt . Errorf ( "failed: %w" , errors .New ("egad" )),
117
116
want : map [string ]interface {}{
118
- "k" : "failed: egad" ,
119
- "kVerbose" : "egad\n failed" ,
117
+ "k" : "failed: egad" ,
120
118
},
121
119
},
122
120
{
123
121
k : "error" ,
124
122
iface : multierr .Combine (
125
- richErrors . WithMessage (
123
+ fmt . Errorf ( "hello: %w" ,
126
124
multierr .Combine (errors .New ("foo" ), errors .New ("bar" )),
127
- "hello" ,
128
125
),
129
126
errors .New ("baz" ),
130
- richErrors . WithMessage ( errors .New ("qux" ), "world" ),
127
+ fmt . Errorf ( "world: %w" , errors .New ("qux" )),
131
128
),
132
129
want : map [string ]interface {}{
133
130
"error" : "hello: foo; bar; baz; world: qux" ,
134
131
"errorCauses" : []interface {}{
135
132
map [string ]interface {}{
136
133
"error" : "hello: foo; bar" ,
137
- "errorVerbose" : "the following errors occurred:\n " +
138
- " - foo\n " +
139
- " - bar\n " +
140
- "hello" ,
141
134
},
142
135
map [string ]interface {}{"error" : "baz" },
143
- map [string ]interface {}{"error" : "world: qux" , "errorVerbose" : "qux \n world" },
136
+ map [string ]interface {}{"error" : "world: qux" },
144
137
},
145
138
},
146
139
},
@@ -161,17 +154,10 @@ func TestErrorEncoding(t *testing.T) {
161
154
func TestRichErrorSupport (t * testing.T ) {
162
155
f := Field {
163
156
Type : ErrorType ,
164
- Interface : richErrors . WithMessage ( richErrors .New ("egad" ), "failed" ),
157
+ Interface : fmt . Errorf ( "failed: %w" , errors .New ("egad" )),
165
158
Key : "k" ,
166
159
}
167
160
enc := NewMapObjectEncoder ()
168
161
f .AddTo (enc )
169
162
assert .Equal (t , "failed: egad" , enc .Fields ["k" ], "Unexpected basic error message." )
170
-
171
- serialized := enc .Fields ["kVerbose" ]
172
- // Don't assert the exact format used by a third-party package, but ensure
173
- // that some critical elements are present.
174
- assert .Regexp (t , `egad` , serialized , "Expected original error message to be present." )
175
- assert .Regexp (t , `failed` , serialized , "Expected error annotation to be present." )
176
- assert .Regexp (t , `TestRichErrorSupport` , serialized , "Expected calling function to be present in stacktrace." )
177
163
}
0 commit comments