Commit Graph

14 Commits (master)

Author SHA1 Message Date
Dave Cheney ee1923e96d Return errors.Frame to a uintptr
Updates aws/aws-xray-sdk-go#77
Updates evalphobia/logrus_sentry#74

Go 1.12 has updated the behaviour of runtime.FuncForPC so that it
behaves as it did in Go 1.11 and earlier.

This allows errors.Frame to return to a uintptr representing the PC +1
of the caller. This will fix the build breakages of projects that were
tracking HEAD of this package.

Signed-off-by: Dave Cheney <dave@cheney.net>
2019-01-09 15:30:26 +11:00
Keith Randall 72fa05efae errors: detect unknown frames correctly (#192)
With Go 1.12, we will now be doing mid-stack inlining. This exposes
inlined frames to runtime.Callers and friends.

The spec says that a runtime.Frame may have a nil Func field for
inlined functions. Instead, use the Function field to detect whether
we really have an empty Frame.
2019-01-09 11:58:33 +11:00
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