Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.

Commit 19140ea

Browse files
committed
Remove deprecated Location interface
1 parent e23d6ed commit 19140ea

File tree

3 files changed

+1
-31
lines changed

3 files changed

+1
-31
lines changed

errors.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,11 @@ func Cause(err error) error {
162162
// Stacktrace() []Frame
163163
// }
164164
//
165-
// type Location interface {
166-
// Location() (file string, line int)
167-
// }
168-
//
169165
// Print will also print the file and line of the error.
170166
// If err is nil, nothing is printed.
171167
//
172168
// Deprecated: Fprint will be removed in version 0.7.
173169
func Fprint(w io.Writer, err error) {
174-
type location interface {
175-
Location() (string, int)
176-
}
177170
type stacktrace interface {
178171
Stacktrace() []Frame
179172
}
@@ -185,10 +178,7 @@ func Fprint(w io.Writer, err error) {
185178
switch err := err.(type) {
186179
case stacktrace:
187180
frame := err.Stacktrace()[0]
188-
fmt.Fprintf(w, "%+s:%d: ", frame, frame)
189-
case location:
190-
file, line := err.Location()
191-
fmt.Fprintf(w, "%s:%d: ", file, line)
181+
fmt.Fprintf(w, "%+v: ", frame)
192182
default:
193183
// de nada
194184
}

stack.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,6 @@ type stack []uintptr
8282
// Deprecated: use Stacktrace()
8383
func (s *stack) Stack() []uintptr { return *s }
8484

85-
// Deprecated: use Stacktrace()[0]
86-
func (s *stack) Location() (string, int) {
87-
frame := s.Stacktrace()[0]
88-
return fmt.Sprintf("%+s", frame), frame.line()
89-
}
90-
9185
func (s *stack) Stacktrace() []Frame {
9286
f := make([]Frame, len(*s))
9387
for i := 0; i < len(f); i++ {

stack_test.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,6 @@ func TestFrameLine(t *testing.T) {
4141
}
4242
}
4343

44-
func TestStackLocation(t *testing.T) {
45-
st := func() *stack {
46-
var pcs [32]uintptr
47-
n := runtime.Callers(1, pcs[:])
48-
var st stack = pcs[0:n]
49-
return &st
50-
}()
51-
file, line := st.Location()
52-
wfile, wline := "github.com/pkg/errors/stack_test.go", 47
53-
if file != wfile || line != wline {
54-
t.Errorf("stack.Location(): want %q %d, got %q %d", wfile, wline, file, line)
55-
}
56-
}
57-
5844
type X struct{}
5945

6046
func (x X) val() Frame {

0 commit comments

Comments
 (0)