@@ -57,13 +57,6 @@ type nilError struct{}
5757
5858func (nilError ) Error () string { return "nil error" }
5959
60- type causeError struct {
61- cause error
62- }
63-
64- func (e * causeError ) Error () string { return "cause error" }
65- func (e * causeError ) Cause () error { return e .cause }
66-
6760func TestCause (t * testing.T ) {
6861 x := New ("error" )
6962 tests := []struct {
@@ -87,7 +80,7 @@ func TestCause(t *testing.T) {
8780 want : io .EOF ,
8881 }, {
8982 // caused error returns cause
90- err : & causeError { cause : io .EOF } ,
83+ err : Wrap ( io .EOF , "ignored" ) ,
9184 want : io .EOF ,
9285 }, {
9386 err : x , // return from errors.New
@@ -118,30 +111,29 @@ func TestFprintError(t *testing.T) {
118111 err : io .EOF ,
119112 want : "EOF\n " ,
120113 }, {
121- // caused error returns cause
122- err : & causeError {cause : io .EOF },
114+ err : Wrap (io .EOF , "cause error" ),
123115 want : "EOF\n " +
124- "cause error\n " ,
116+ "github.com/pkg/errors/errors_test.go:114: cause error\n " ,
125117 }, {
126118 err : x , // return from errors.New
127- want : "github.com/pkg/errors/errors_test.go:106 : error\n " ,
119+ want : "github.com/pkg/errors/errors_test.go:99 : error\n " ,
128120 }, {
129121 err : Wrap (x , "message" ),
130- want : "github.com/pkg/errors/errors_test.go:106 : error\n " +
131- "github.com/pkg/errors/errors_test.go:129 : message\n " ,
122+ want : "github.com/pkg/errors/errors_test.go:99 : error\n " +
123+ "github.com/pkg/errors/errors_test.go:121 : message\n " ,
132124 }, {
133125 err : Wrap (io .EOF , "message" ),
134126 want : "EOF\n " +
135- "github.com/pkg/errors/errors_test.go:133 : message\n " ,
127+ "github.com/pkg/errors/errors_test.go:125 : message\n " ,
136128 }, {
137129 err : Wrap (Wrap (x , "message" ), "another message" ),
138- want : "github.com/pkg/errors/errors_test.go:106 : error\n " +
139- "github.com/pkg/errors/errors_test.go:137 : message\n " +
140- "github.com/pkg/errors/errors_test.go:137 : another message\n " ,
130+ want : "github.com/pkg/errors/errors_test.go:99 : error\n " +
131+ "github.com/pkg/errors/errors_test.go:129 : message\n " +
132+ "github.com/pkg/errors/errors_test.go:129 : another message\n " ,
141133 }, {
142134 err : Wrapf (x , "message" ),
143- want : "github.com/pkg/errors/errors_test.go:106 : error\n " +
144- "github.com/pkg/errors/errors_test.go:142 : message\n " ,
135+ want : "github.com/pkg/errors/errors_test.go:99 : error\n " +
136+ "github.com/pkg/errors/errors_test.go:134 : message\n " ,
145137 }}
146138
147139 for i , tt := range tests {
0 commit comments