22 Commits

Author SHA1 Message Date
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
d7cdef1704 Remove Fprint (#47) 2016-06-10 11:53:11 +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
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
3dc37da2ca Reverse the order of Fprint output (#43)
Fprint should match the stack output, innermost error first.

It probably doesn't matter as Fprint is going away.
2016-06-09 20:02:11 +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
Dave Cheney
e8c21980b6 Make errors.stack comparable (#30)
Fixed #29

errors.New, etc values are not expected to be compared by value but
the change in errors#27 made them incomparable. Assert that various
kinds of errors have a functional equality operator, even if the
result of that equality is always false.
2016-05-24 12:36:43 +10:00
Dave Cheney
abe54b4bad Added more Stack tests 2016-05-23 19:19:03 +10:00
Dave Cheney
cc157cd49f Store the stack of the caller to New, Errorf, Wrap and Wrapf (#27)
Store up to 32 stack frames for the caller to New, Errorf, Wrap, and
Wrapf.
2016-05-23 18:47:43 +10:00
Santiago Corredoira Lascaray
7a0abd8f63 Add Errorf (#14) 2016-04-30 08:38:57 +10:00
Umair Idris
9a179122f1 Add Wrapf 2016-04-25 00:31:25 -04:00
Umair Idris
c94cbcebe9 gofmt and typo fix 2016-04-24 15:34:22 -04:00
Anthony Yeh
44b2f1e7ac Don't pass arbitrary strings as Errorf() format strings.
Sometimes they happen to contain format specifiers, which results in
things like "%!v(MISSING)".
2016-04-24 00:08:22 -07:00
Dave Cheney
4df5f1c4b6 added example, fixed tests 2016-04-22 19:13:47 +09:00
Dave Cheney
a7f2be0bfe added godoc 2016-04-22 19:10:04 +09:00
Dave Cheney
5a0856ff23 fixed tests, add coverage for Wrap and Fprintf 2016-04-22 17:27:54 +09:00
Dave Cheney
c978824ef0 wip 2016-04-20 13:14:31 +09:00
Dave Cheney
7b7bdcfe0a Remove New, replace with Wrap. 2016-03-28 13:44:17 +11:00
Dave Cheney
105e86fc3b fixing layout to make Andy happy 2015-12-27 16:12:56 +01:00
Dave Cheney
9c1c579e61 remove causer 2015-12-27 15:58:27 +01:00
Dave Cheney
4dd713cae9 Added cause interface trait 2015-12-27 15:45:25 +01:00
Dave Cheney
1e412a1049 Added New and Cause methods. 2015-12-27 15:19:49 +01:00