132 Commits

Author SHA1 Message Date
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
Dave Cheney
537896ad6e
travis: remove Go 1.8 and earlier (#182)
Remove support for Go 1.8 and earlier as they are

a. no longer supported upstream
b. lack support for runtime.CallerFrames

Signed-off-by: Dave Cheney <dave@cheney.net>
2019-01-05 15:00:06 +11:00
Dave Cheney
31aac83bad
travis: use Makefile (#181)
Add a bunch of useful makefile targets

Signed-off-by: Dave Cheney <dave@cheney.net>
2019-01-05 14:54:17 +11:00
Dave Cheney
5ac96aea29
Update README.md 2019-01-05 13:32:11 +11:00
Tariq Ibrahim
ba968bfe8b gofmt -w errors.go (#179) v0.8.1 2019-01-03 17:52:24 +11:00
Komu Wairagu
059132a15d Update .travis.yml (#168) 2018-10-24 10:59:46 +11:00
Harald Nordgren
d58f942510 Bump Travis versions (#172) 2018-10-21 09:29:33 +11:00
Steven E. Harris
2233dee583 Copyedit the package documentation (#135)
Remove spurious words, add missing words, and smooth out a few
sentences.
2018-10-08 15:53:15 +11:00
Dariusz Jedrzejczyk
e981d1a2c5 Add WithMessagef function (#118)
WithMessagef utility function to accompany WithMessage, similar to
exiting Wrapf function accompanying Wrap.
2018-10-08 15:50:16 +11:00
Eldar Rakhimberdin
c059e472ca fixed spelling (#156) 2018-09-11 16:21:13 +10:00
Dave Cheney
816c908556
travis.yml: add Go 1.10 (#154) 2018-03-12 08:45:15 +11:00
Mark Ayers
30136e27e2 Remove deadcode (#146) 2018-01-27 12:58:12 +11:00
Tom Sweeney
e881fd58d7 Fix minor typo in README.md (#142)
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2017-12-16 18:03:16 +11:00
Nick Snyder
8842a6e0cc Add badge for number of dependent libraries (#109) 2017-12-10 13:24:16 +11:00
Tibor Benke
e4f5060297 Fix doc comment for exported Format func (#137)
Fixes #136

Signed-off-by: Tibor Benke <ihrwein@gmail.com>
2017-12-10 10:30:25 +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
Davor Kapsa
2b3a18b5f0 travis: add 1.9.x to go versions (#133) 2017-09-10 23:46:14 +10:00
Matthew Hardwick
c605e284fe Add doc comment for exported Format func (#115) 2017-05-05 14:36:39 +10:00
Alexey Palazhchenko
ff09b135c2 Bump Go versions, use latest patch releases (#110) 2017-03-17 07:15:38 +11:00
Bradley Falzon
bfd5150e4e Move benchmark assigned err to global exported variable (#106)
toperr is not used, but the go compiler itself doesn't detect this
because it's within an anonymous function. However, go/types does
detect this as being unused, which causes any static analysis tools
which uses go/types' type checker to fail with the message "toperr
assigned and not used".

The final result of the benchmarked function is instead assigned to
an exported global variable to ensure the compiler cannot now, nor
in the future optimise away the function calls due to no observable
side effects.

It was chosen to assign the final result, after the benchmark loop,
to the global variable, as this best follows the example set in the
CL https://go-review.googlesource.com/#/c/37195/. As opposed to
having each call to f assign to the global. This also appears to
better align with the original author's intention of toperr.

This change had no observable impact on the benchmark.

Related https://github.com/golang/go/issues/3059.
Related https://github.com/golang/go/issues/8560.

Thanks dominikh for additional clarifications.
2017-02-28 09:00:37 +11:00
Alexey Palazhchenko
248dadf4e9 Bump Go versions (#91) 2016-10-29 20:36:37 +11:00
Nick Miyake
839d9e913e Fix minor newline consistency issues in test files (#87) 2016-10-02 16:25:12 +11:00
Dave Cheney
645ef00459 doc tweaks v0.8.0 2016-09-29 11:48:01 +10:00
Dave Cheney
7433cb070c fix line numbers in fmt tests 2016-09-29 11:32:15 +10:00
Nick Miyake
3a4fafe48b Fix comment on WithMessage function (#86) 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
542b81d67c minor: refactored small loop 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
Dave Cheney
4f8d1cf2a2 Revert "Remove WithStack and WithMessage public functions"
This reverts commit 1b876e063eebebbcbab83aafa8bc631edef98fff.
2016-09-29 11:32:15 +10:00
Thomas de Zeeuw
a887431f7f Add Go 1.7.1 to Travis (#85) 2016-09-16 21:02:12 +10:00
Nick Craig-Wood
17b591df37 Fix the %q format for errors so it puts "" around the output (#83) v0.7.1 2016-08-22 10:00:10 +01:00
Dave Cheney
a22138067a remove incorrect comment 2016-08-08 15:55:40 +10:00
Dave Cheney
9cadab9279 Merge pull request #81 from pkg/withMessage-withStack
Refactor withMessage/withStack
2016-08-08 14:49:31 +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
Dave Cheney
785921b1c1 Destructure New/Errorf
Destructure New/Errorf into two components, a call to the stdlib
errors.New or fmt.Errorf to generate a _fundamental_ error, and then a
call to withStack to attach a stack trace to the message.
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
Daniel Theophanes
1d2e60385a errors: add a benchmark comparing stack trace performance (#74)
Fixes #72
2016-07-24 12:43:27 +10:00
Alexey Palazhchenko
cc5fbb72d9 Documentation improvements (#69)
* Add install instructions.

* Document that causer and stackTracer are stable.
2016-07-19 19:13:40 +10:00
Vincent Batts
a2d6902c6d LICENSE: remove trailing newline (#61)
Discovered while vendoring this repo, and having a check for trailing
whitespace. (e.g. `git show --check 45e9319`)

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-06-28 08:23:52 +10:00
Jon Gillham
d62207b3dc Capitalise first letter of trace. (#60) 2016-06-27 12:13:31 +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
494e70f762 Rename StackTrace interface to stacktracer in docs and examples (#56) 2016-06-16 17:40:57 +10:00
Uwe Dauernheim
01fa4104b9 Align code example documentation (#52) v0.7.0 2016-06-13 12:17:47 +10:00
Dave Cheney
73d71e4a6a Rename Stacktrace to StackTrace (#51)
Fixes #50
2016-06-13 11:11:14 +10:00
Dave Cheney
784931b43c rename errors.New parameter to message 2016-06-13 10:58:08 +10:00
Dave Cheney
9a4f977a05 document extended format 2016-06-11 23:12:34 +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