Skip to content

Commit

Permalink
simplify pc
Browse files Browse the repository at this point in the history
  • Loading branch information
davecheney committed Apr 22, 2016
1 parent 258d126 commit 109ee59
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ func (l loc) Location() (string, int) {

// New returns an error that formats as the given text.
func New(text string) error {
pc, _, _, _ := runtime.Caller(1)
return struct {
error
loc
}{
fmt.Errorf(text),
loc(pc()),
loc(pc),
}
}

Expand All @@ -57,10 +58,11 @@ func Wrap(cause error, message string) error {
if cause == nil {
return nil
}
pc, _, _, _ := runtime.Caller(1)
return &e{
cause: cause,
message: message,
loc: loc(pc()),
loc: loc(pc),
}
}

Expand Down Expand Up @@ -132,8 +134,3 @@ func Fprint(w io.Writer, err error) {
err = cause.Cause()
}
}

func pc() uintptr {
pc, _, _, _ := runtime.Caller(2)
return pc
}

0 comments on commit 109ee59

Please sign in to comment.