renamed CallTrace to CallStack and implemented Error.Stack() method

This commit is contained in:
milarin
2023-07-27 19:20:02 +02:00
parent ad6d42b35c
commit 1bc43397d6
3 changed files with 17 additions and 13 deletions

View File

@ -6,15 +6,15 @@ import (
"strings"
)
// CallTrace represents a call stack trace similar to Java's stack trace
type CallTrace struct {
// CallStack represents a call stack trace similar to Java's stack trace
type CallStack struct {
frames *runtime.Frames
more bool
}
// Trace returns a new CallTrace starting from this call
// Use skip to skip the first entries in the trace
func Trace(skip int) *CallTrace {
func Trace(skip int) *CallStack {
if DisableTrace {
return nil
}
@ -22,10 +22,10 @@ func Trace(skip int) *CallTrace {
pc := make([]uintptr, CallStackLength+1)
n := runtime.Callers(skip+1, pc)
pc = pc[:n]
return &CallTrace{runtime.CallersFrames(pc), n == CallStackLength+1}
return &CallStack{runtime.CallersFrames(pc), n == CallStackLength+1}
}
func (ct *CallTrace) String() string {
func (ct *CallStack) String() string {
if ct == nil {
return ""
}