@@ -55,11 +55,11 @@ import (
5555 "strings"
5656)
5757
58- // location represents a stack of programm counters.
59- type location []uintptr
58+ // stack represents a stack of programm counters.
59+ type stack []uintptr
6060
61- func (l location ) Location () (string , int ) {
62- pc := l [0 ] - 1
61+ func (s stack ) Location () (string , int ) {
62+ pc := s [0 ] - 1
6363 fn := runtime .FuncForPC (pc )
6464 if fn == nil {
6565 return "unknown" , 0
@@ -111,10 +111,10 @@ func (l location) Location() (string, int) {
111111func New (text string ) error {
112112 return struct {
113113 error
114- location
114+ stack
115115 }{
116116 errors .New (text ),
117- caller (),
117+ callers (),
118118 }
119119}
120120
@@ -132,10 +132,10 @@ func (c cause) Message() string { return c.message }
132132func Errorf (format string , args ... interface {}) error {
133133 return struct {
134134 error
135- location
135+ stack
136136 }{
137137 fmt .Errorf (format , args ... ),
138- caller (),
138+ callers (),
139139 }
140140}
141141
@@ -145,7 +145,7 @@ func Wrap(cause error, message string) error {
145145 if cause == nil {
146146 return nil
147147 }
148- return wrap (cause , message , caller ())
148+ return wrap (cause , message , callers ())
149149}
150150
151151// Wrapf returns an error annotating the cause with the format specifier.
@@ -154,19 +154,19 @@ func Wrapf(cause error, format string, args ...interface{}) error {
154154 if cause == nil {
155155 return nil
156156 }
157- return wrap (cause , fmt .Sprintf (format , args ... ), caller ())
157+ return wrap (cause , fmt .Sprintf (format , args ... ), callers ())
158158}
159159
160- func wrap (err error , msg string , loc location ) error {
160+ func wrap (err error , msg string , st stack ) error {
161161 return struct {
162162 cause
163- location
163+ stack
164164 }{
165165 cause {
166166 cause : err ,
167167 message : msg ,
168168 },
169- loc ,
169+ st ,
170170 }
171171}
172172
@@ -235,8 +235,9 @@ func Fprint(w io.Writer, err error) {
235235 }
236236}
237237
238- func caller () location {
239- var pcs [1 ]uintptr
238+ func callers () stack {
239+ const depth = 1
240+ var pcs [depth ]uintptr
240241 n := runtime .Callers (3 , pcs [:])
241- return location ( pcs [0 :n ])
242+ return pcs [0 :n ]
242243}
0 commit comments