File tree Expand file tree Collapse file tree 2 files changed +5
-13
lines changed Expand file tree Collapse file tree 2 files changed +5
-13
lines changed Original file line number Diff line number Diff line change @@ -214,7 +214,6 @@ func pad(buf *bytes.Buffer, pad string) {
214214func New (args ... interface {}) * Error {
215215 err := newError (args ... )
216216
217- updateLocation (err )
218217 updateCaller (err )
219218
220219 return err
@@ -269,7 +268,6 @@ func Wrap(cause error, args ...interface{}) *Error {
269268 err := newError (args ... )
270269
271270 // We have to set these again, as they'll be at the wrong depth now.
272- updateLocation (err )
273271 updateCaller (err )
274272
275273 return err
@@ -286,15 +284,10 @@ func updateCaller(err *Error) {
286284
287285 fun := runtime .FuncForPC (fpcs [0 ] - 1 )
288286 if fun != nil {
289- funcName := strings .Split (fun .Name (), "/" )
290- err .caller = funcName [len (funcName )- 1 ]
291- }
292- }
287+ li := strings .LastIndex (fun .Name (), "/" ) + 1
293288
294- // updateLocation takes an error and sets file and line information on it. Safe to use in error
295- // constructors, but no deeper.
296- func updateLocation (err * Error ) {
297- _ , file , line , _ := runtime .Caller (2 )
298- err .file = file
299- err .line = line
289+ funcName := fun .Name ()[li :]
290+ err .caller = funcName
291+ err .file , err .line = fun .FileLine (fpcs [0 ] - 1 )
292+ }
300293}
Original file line number Diff line number Diff line change @@ -16,7 +16,6 @@ func Fatal(err error) {
1616
1717 wrapped := newError (err )
1818
19- updateLocation (wrapped )
2019 updateCaller (wrapped )
2120
2221 if v , ok := err .(* Error ); ok {
You can’t perform that action at this time.
0 commit comments