12 Commits

Author SHA1 Message Date
haya14busa
f15c970de5 Remove an unused argument of utility test func (#139)
Found this by https://github.com/mvdan/unparam
2017-10-19 06:55:49 +11:00
Dave Cheney
7433cb070c fix line numbers in fmt tests 2016-09-29 11:32:15 +10:00
fabstu
1398fbcad1 tests: fixed tests on 1.4. 2016-09-29 11:32:15 +10:00
fabstu
162fea7c06 tests: added recursively trying out combinations of calls for %+v. 2016-09-29 11:32:15 +10:00
fabstu
011399d349 Add WithStack and WithMessage tests
Adds testFormatCompleteCompare as additional testing func.

The new function takes a string slice as "want", wherein
stacktraces and non-stacktrace messages are discerned by
strings.ContainsAny(want[i], "\n").

For example usage, see TestFormatWithStack & TestFormatWithMessage.
2016-09-29 11:32:15 +10:00
Nick Craig-Wood
17b591df37 Fix the %q format for errors so it puts "" around the output (#83) 2016-08-22 10:00:10 +01:00
Dave Cheney
777ed74de5 Destructure Wrap{,f} into WithStack(WithMessage(err, msg))
Introduces WithMessage as well as errors.fundamental, errors.withMessage
and errors.withStack internal types.

Adjust tests for the new wrapped format when combining fundamental and
wrapped errors.
2016-08-08 14:31:22 +10:00
Darshan Shaligram
cbd18b5440 Fix %q format for wrapped errors (#58)
Not handling the %q format causes logrus to log empty error strings for
wrapped errors where x.Error() contains spaces or other quoteworthy
characters.

For reference, the logrus formatter does this:
https://github.com/Sirupsen/logrus/blob/master/text_formatter.go#L154
2016-06-22 11:00:19 +10:00
Dave Cheney
0bc61eb85b Wrapper errors now print full stacktrace (#57) 2016-06-19 14:34:20 +10:00
Dave Cheney
7896481a53 Extended stacktrace output (#49)
* Extended stacktrace output

* Make format tests less sensitive to sourcecode prefix

* use testFormatRegexp for all Sprintf tests

* replace output test with sample output

* work around the different fn.Name format in go 1.4

* fix windows tests when there is a drive letter in the source path
2016-06-11 23:04:57 +10:00
Dave Cheney
874c0ec5b0 Reimplement Fprint in terms of fmt.Fprintf (#44)
This PR follows on from #40 completely implementing Fprint in terms of
fmt.Fprintf. This will be the final PR before Fprint is removed.
2016-06-10 08:39:59 +10:00
Dave Cheney
c0c662e216 Use fmt.Formatter throughout (#40)
* Use fmt.Formatter throughout

Replace Fprintf with fmt.Formatter logic on various types. This
effectively guts Fprint to be just a recursive call down the err.Cause
chain. The next step will be to move this recursive logic into
wrapper.Format.

This change necessitates adding types for the error impls returned from
New and Errorf, and Wrap and Wrapf, respectively. The name of the latter
type is acceptable, the former is not and alternative suggestions are
encouraged.

- Remove cause.Format
- Added fmt.Formatter tests. The location is temporary, once this PR is merged and Fprint removed
they will be merged into errors_test.go
2016-06-09 16:45:08 +10:00