Commit Graph

20 Commits (master)

Author SHA1 Message Date
Adrian Perez 004deef562
remove unnecessary use of fmt.Sprintf (#217)
* remove unnecessary use of fmt.Sprintf
2020-01-03 13:36:54 +01:00
Dave Cheney ffb6e22f01
Reduce allocations in StackTrace.Format (#194)
Updates #150

Signed-off-by: Dave Cheney <dave@cheney.net>
2019-01-09 17:16:28 +11:00
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
Dave Cheney 584cbace28
Remove checks for old style anon funcs (#186)
Signed-off-by: Dave Cheney <dave@cheney.net>
2019-01-05 21:07:35 +11:00
Dave Cheney e19cb699ad
Remove last reference to runtime.FuncForPC (#184)
Signed-off-by: Dave Cheney <dave@cheney.net>
2019-01-05 19:41:10 +11:00
Dave Cheney 4f47277723
Switch to runtime.CallersFrames (#183)
Fixes #160
Fixes #107

Signed-off-by: Dave Cheney <dave@cheney.net>
2019-01-05 19:23:03 +11:00
Mark Ayers 30136e27e2 Remove deadcode (#146) 2018-01-27 12:58:12 +11:00
fabstu 1398fbcad1 tests: fixed tests on 1.4. 2016-09-29 11:32:15 +10:00
Dave Cheney 4f8d1cf2a2 Revert "Remove WithStack and WithMessage public functions"
This reverts commit 1b876e063e.
2016-09-29 11:32:15 +10:00
Dave Cheney 1b876e063e Remove WithStack and WithMessage public functions
The refactoring to use withStack and withMessage types is useful enough
to land indepdently of exposing these helpers publically.
2016-08-08 14:39:38 +10: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
Paul Robins 2a9be18ecd Modify TestTrimGOPATH to ensure tests pass while vendored (#78) 2016-08-01 20:26:19 +10:00
Jon Gillham d62207b3dc Capitalise first letter of trace. (#60) 2016-06-27 12:13:31 +10:00
Dave Cheney 73d71e4a6a Rename Stacktrace to StackTrace (#51)
Fixes #50
2016-06-13 11:11:14 +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 a5b220e0c6 Introduce errors.Stacktrace (#48)
* Introduce errors.Stacktrace

Introduce a new type to replace the unnamed return value from
`Stacktrace()`. `Stacktrace` implements `fmt.Formatter` and currently
replicates the default behaviour of printing a `[]Frame`.

In a future PR the values of `%+v` and `%#v` will be extended to
implement a more readable stacktrace.
2016-06-10 14:10:18 +10:00
Dave Cheney 5776abf3b9 Remove deprecated Stack() []uintptr interface (#45)
* Remove deprecated Stack() []uintptr interface

* move TestStack to TestStacktrace
2016-06-10 00:48:07 +10:00
Dave Cheney 19140ea8c4 Remove deprecated Location interface 2016-06-08 19:34:10 +10:00
Dave Cheney e23d6edfd2 extract funcname helper, and add test 2016-06-08 19:21:37 +10:00
Dave Cheney 3cdd33210d Introduce Stacktrace and Frame (#37)
* Introduce Stacktrace and Frame

This PR is a continuation of a series aimed at exposing the stack trace
information embedded in each error value. The secondary effect is to
deprecated the `Fprintf` helper.

Taking cues from from @chrishines' `stack` package this PR introduces a
new interface `Stacktrace() []Frame` and a `Frame` type, similar in
function to the `runtime.Frame` type (although lacking its iterator
type). Each `Frame` implemnts `fmt.Formatter` allowing it to print
itself.

The older `Location` interface is still supported but also deprecated.
2016-06-07 14:23:05 +10:00