Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TraceCaller interface for extensibility for #104 #106

Merged
merged 9 commits into from
May 6, 2024
6 changes: 3 additions & 3 deletions unwrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ func UnwrapFrame(err error) (frame runtime.Frame, inner error, ok bool) { //noli
return runtime.Frame{}, err, false
}

wrapErr := errors.Unwrap(err)
inner = errors.Unwrap(err)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that inner is a better name. wrapErr was a silly play on wrapper, but I still get to giggle when any error name's last syllable can be pronounced err. 😄

frames := runtime.CallersFrames([]uintptr{e.TracePC()})
f, _ := frames.Next()
if f == (runtime.Frame{}) {
// Unlikely, but if PC didn't yield a frame,
// just return the inner error.
return runtime.Frame{}, wrapErr, false
return runtime.Frame{}, inner, false
}

return f, wrapErr, true
return f, inner, true
}
Loading