github.com/asynkron/protoactor-go@v0.0.0-20240308120642-ef91a6abee75/internal/core/debug.go (about) 1 package core 2 3 import ( 4 "fmt" 5 "runtime" 6 "strings" 7 ) 8 9 func IdentifyPanic() string { 10 var name, file string 11 var line int 12 var pc [16]uintptr 13 14 n := runtime.Callers(3, pc[:]) 15 for _, pc := range pc[:n] { 16 fn := runtime.FuncForPC(pc) 17 if fn == nil { 18 continue 19 } 20 file, line = fn.FileLine(pc) 21 name = fn.Name() 22 if !strings.HasPrefix(name, "runtime.") { 23 break 24 } 25 } 26 27 switch { 28 case name != "": 29 return fmt.Sprintf("%v:%v", name, line) 30 case file != "": 31 return fmt.Sprintf("%v:%v", file, line) 32 } 33 34 return fmt.Sprintf("pc:%x", pc) 35 }