Skip to content

Commit

Permalink
Remove deprecated Location interface
Browse files Browse the repository at this point in the history
  • Loading branch information
davecheney committed Jun 8, 2016
1 parent e23d6ed commit 19140ea
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 31 deletions.
12 changes: 1 addition & 11 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,11 @@ func Cause(err error) error {
// Stacktrace() []Frame
// }
//
// type Location interface {
// Location() (file string, line int)
// }
//
// Print will also print the file and line of the error.
// If err is nil, nothing is printed.
//
// Deprecated: Fprint will be removed in version 0.7.
func Fprint(w io.Writer, err error) {
type location interface {
Location() (string, int)
}
type stacktrace interface {
Stacktrace() []Frame
}
Expand All @@ -185,10 +178,7 @@ func Fprint(w io.Writer, err error) {
switch err := err.(type) {
case stacktrace:
frame := err.Stacktrace()[0]
fmt.Fprintf(w, "%+s:%d: ", frame, frame)
case location:
file, line := err.Location()
fmt.Fprintf(w, "%s:%d: ", file, line)
fmt.Fprintf(w, "%+v: ", frame)
default:
// de nada
}
Expand Down
6 changes: 0 additions & 6 deletions stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ type stack []uintptr
// Deprecated: use Stacktrace()
func (s *stack) Stack() []uintptr { return *s }

// Deprecated: use Stacktrace()[0]
func (s *stack) Location() (string, int) {
frame := s.Stacktrace()[0]
return fmt.Sprintf("%+s", frame), frame.line()
}

func (s *stack) Stacktrace() []Frame {
f := make([]Frame, len(*s))
for i := 0; i < len(f); i++ {
Expand Down
14 changes: 0 additions & 14 deletions stack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,6 @@ func TestFrameLine(t *testing.T) {
}
}

func TestStackLocation(t *testing.T) {
st := func() *stack {
var pcs [32]uintptr
n := runtime.Callers(1, pcs[:])
var st stack = pcs[0:n]
return &st
}()
file, line := st.Location()
wfile, wline := "github.com/pkg/errors/stack_test.go", 47
if file != wfile || line != wline {
t.Errorf("stack.Location(): want %q %d, got %q %d", wfile, wline, file, line)
}
}

type X struct{}

func (x X) val() Frame {
Expand Down

0 comments on commit 19140ea

Please sign in to comment.