diff --git a/errors.go b/errors.go index 0168061..4e2e967 100644 --- a/errors.go +++ b/errors.go @@ -173,22 +173,6 @@ func AddStack(err error) error { return WithStack(err) } -// GetStackTracer will return the first StackTracer in the causer chain. -// This function is used by AddStack to avoid creating redundant stack traces. -// -// You can also use the StackTracer interface on the returned error to get the stack trace. -func GetStackTracer(origErr error) StackTracer { - var stacked StackTracer - WalkDeep(origErr, func(err error) bool { - if stackTracer, ok := err.(StackTracer); ok { - stacked = stackTracer - return true - } - return false - }) - return stacked -} - type withStack struct { error *stack diff --git a/stack.go b/stack.go index 6edd7e5..cbebb62 100644 --- a/stack.go +++ b/stack.go @@ -14,6 +14,22 @@ type StackTracer interface { StackTrace() StackTrace } +// GetStackTracer will return the first StackTracer in the causer chain. +// This function is used by AddStack to avoid creating redundant stack traces. +// +// You can also use the StackTracer interface on the returned error to get the stack trace. +func GetStackTracer(origErr error) StackTracer { + var stacked StackTracer + WalkDeep(origErr, func(err error) bool { + if stackTracer, ok := err.(StackTracer); ok { + stacked = stackTracer + return true + } + return false + }) + return stacked +} + // Frame represents a program counter inside a stack frame. type Frame uintptr