mirror of
https://github.com/pkg/errors.git
synced 2025-05-05 07:00:33 +00:00
simplify pc
This commit is contained in:
parent
258d1265c4
commit
109ee590a8
11
errors.go
11
errors.go
@ -28,12 +28,13 @@ func (l loc) Location() (string, int) {
|
|||||||
|
|
||||||
// New returns an error that formats as the given text.
|
// New returns an error that formats as the given text.
|
||||||
func New(text string) error {
|
func New(text string) error {
|
||||||
|
pc, _, _, _ := runtime.Caller(1)
|
||||||
return struct {
|
return struct {
|
||||||
error
|
error
|
||||||
loc
|
loc
|
||||||
}{
|
}{
|
||||||
fmt.Errorf(text),
|
fmt.Errorf(text),
|
||||||
loc(pc()),
|
loc(pc),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,10 +58,11 @@ func Wrap(cause error, message string) error {
|
|||||||
if cause == nil {
|
if cause == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
pc, _, _, _ := runtime.Caller(1)
|
||||||
return &e{
|
return &e{
|
||||||
cause: cause,
|
cause: cause,
|
||||||
message: message,
|
message: message,
|
||||||
loc: loc(pc()),
|
loc: loc(pc),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,8 +134,3 @@ func Fprint(w io.Writer, err error) {
|
|||||||
err = cause.Cause()
|
err = cause.Cause()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func pc() uintptr {
|
|
||||||
pc, _, _, _ := runtime.Caller(2)
|
|
||||||
return pc
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user