Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
komuw committed Mar 1, 2024
1 parent f3a4ee2 commit ca813c1
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,35 @@ func getStackTrace() []string {
}
}

n := 0
txtLast := ""
txtLastButOne := ""
if len(frms) > 0 {
txtLast = readLastLine(frms[0].file, int64(frms[0].line))
for k, _ := range frms {
if strings.Contains(frms[k].file, "/kama/") || strings.Contains(frms[k].file, "go/src/") {
// Do not display expanded source code for this library or Go runtime.
n = n + 1
} else {
break
}
}

if len(frms) > n {
txtLast = readLastLine(frms[n].file, int64(frms[n].line))
}
if len(frms) > 1 {
txtLastButOne = readLastLine(frms[1].file, int64(frms[1].line))
next := n + 1
if len(frms) > next {
txtLastButOne = readLastLine(frms[next].file, int64(frms[next].line))
}

traces := []string{}
for k, v := range frms {
traces = append(traces, fmt.Sprintf("\t%s:%d %s", v.file, v.line, v.function))

if k == 0 && txtLast != "" {
if k == n && txtLast != "" {
traces = append(traces, txtLast)
}

if k == 1 && txtLastButOne != "" {
if k == next && txtLastButOne != "" {
traces = append(traces, txtLastButOne)
}
}
Expand Down

0 comments on commit ca813c1

Please sign in to comment.