Skip to content

Commit

Permalink
Add TopFrame function
Browse files Browse the repository at this point in the history
  • Loading branch information
kazukousen committed Jan 9, 2024
1 parent 4a500fe commit 88cf9b3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@ import (
"github.com/pkg/errors"
)

type ErrorSets []ErrorSet

func (es ErrorSets) TopFrame() *Frame {
if len(es) == 0 {
return nil
} else if len(es[0].Frames) == 0 {
return nil
}

top := es[0].Frames

if p := es[0].Parent; p != nil {
top = top.Exclude(p)
}
if len(top) == 0 {
return nil
}

return top[0]
}

type ErrorSet struct {
Error error
Frames Frames
Expand Down

0 comments on commit 88cf9b3

Please sign in to comment.