Wrapper errors now print full stacktrace (#57)
diff --git a/errors.go b/errors.go
index ab18602..216b768 100644
--- a/errors.go
+++ b/errors.go
@@ -145,7 +145,8 @@
case 'v':
if s.Flag('+') {
fmt.Fprintf(s, "%+v\n", w.Cause())
- fmt.Fprintf(s, "%+v: %s", w.StackTrace()[0], w.msg)
+ io.WriteString(s, w.msg)
+ fmt.Fprintf(s, "%+v", w.StackTrace())
return
}
fallthrough
diff --git a/format_test.go b/format_test.go
index 60806ae..a862087 100644
--- a/format_test.go
+++ b/format_test.go
@@ -107,8 +107,9 @@
Wrap(io.EOF, "error"),
"%+v",
"EOF\n" +
+ "error\n" +
"github.com/pkg/errors.TestFormatWrapf\n" +
- "\t.+/github.com/pkg/errors/format_test.go:107: error",
+ "\t.+/github.com/pkg/errors/format_test.go:107",
}, {
Wrapf(New("error"), "error%d", 2),
"%v",
@@ -118,7 +119,14 @@
"%+v",
"error\n" +
"github.com/pkg/errors.TestFormatWrapf\n" +
- "\t.+/github.com/pkg/errors/format_test.go:117",
+ "\t.+/github.com/pkg/errors/format_test.go:118",
+ }, {
+ Wrap(Wrap(io.EOF, "error1"), "error2"),
+ "%+v",
+ "EOF\n" +
+ "error1\n" +
+ "github.com/pkg/errors.TestFormatWrapf\n" +
+ "\t.+/github.com/pkg/errors/format_test.go:124\n",
}}
for _, tt := range tests {