Skip to content

Commit ea2ad23

Browse files
committed
[patch] updated tests
[patch] updated Message() to return Error() if empty
1 parent d9a4fa5 commit ea2ad23

File tree

3 files changed

+390
-6
lines changed

3 files changed

+390
-6
lines changed

errors.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,11 @@ func (e *Error) Message() string {
104104
return strings.Join(messages, ". ")
105105
}
106106

107-
return e.message
107+
return e.Error()
108108
}
109109

110110
// Unwrap implement's Go 1.13's Unwrap interface exposing the wrapped error
111111
func (e *Error) Unwrap() error {
112-
if e.original == nil {
113-
return nil
114-
}
115-
116112
return e.original
117113
}
118114

errors_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ func Benchmark_Internal(b *testing.B) {
180180
Internal("hello world")
181181
}
182182
}
183+
func Benchmark_Internalf(b *testing.B) {
184+
for i := 0; i < b.N; i++ {
185+
Internalf("%s prefixed", "hello world")
186+
}
187+
}
183188

184189
func Benchmark_InternalErr(b *testing.B) {
185190
err := errors.New("bad error")
@@ -251,7 +256,7 @@ func TestError_Message(t *testing.T) {
251256
eType: TypeInternal,
252257
fileLine: "errors.go:87",
253258
},
254-
want: "",
259+
want: "errors.go:87 unknown error occurred",
255260
},
256261
{
257262
name: "Nested error with message",

0 commit comments

Comments
 (0)