diff --git a/callstack/stack.go b/callstack/stack.go index a1031bf..fa4ccc3 100644 --- a/callstack/stack.go +++ b/callstack/stack.go @@ -1,7 +1,6 @@ package callstack import ( - "errors" "fmt" "iter" "runtime" @@ -36,26 +35,6 @@ func GetSkip(skip int) Stack { } } -// FromError attempts to get a [Stack] that's embedded into an error. It returns -// the first [Stack] found. -func FromError(err error) (st Stack, found bool) { - for err != nil { - if getter, ok := err.(interface{ get() Stack }); ok { - st = getter.get() - found = true - return - } - - err = errors.Unwrap(err) - } - - return -} - -func (st Stack) get() Stack { - return st -} - // A shallow wrapper around [runtime.CallersFrames] func (st Stack) CallersFrames() *runtime.Frames { return runtime.CallersFrames(st.s) diff --git a/callstack/stack_test.go b/callstack/stack_test.go index 927e080..a630b38 100644 --- a/callstack/stack_test.go +++ b/callstack/stack_test.go @@ -1,8 +1,6 @@ package callstack import ( - "errors" - "fmt" "reflect" "strings" "testing" @@ -38,32 +36,6 @@ func TestGet(t *testing.T) { c.Equal(frames[depth].Function, funcName) } -func TestFromError(t *testing.T) { - c := check.NewT(t) - - type embed struct { - Stack - error - } - - deep := embed{ - Stack: Get(), - error: errors.New("test"), - } - - err := fmt.Errorf("%s: %w", "wrap", deep) - for range 5 { - st, found := FromError(err) - c.True(found) - c.Equal(deep.Stack, st) - - err = fmt.Errorf("%s: %w", "wrap", deep) - } - - _, found := FromError(errors.New("merp")) - c.False(found) -} - func TestStackIters(t *testing.T) { recurse(10, func() any { for _ = range Get().All() {