github.com/haraldrudell/parl@v0.4.176/g0/g0debug/go-error-dump.go (about) 1 /* 2 © 2023–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/) 3 ISC License 4 */ 5 6 package g0debug 7 8 import ( 9 "fmt" 10 11 "github.com/haraldrudell/parl" 12 "github.com/haraldrudell/parl/perrors" 13 ) 14 15 // GoErrorDump prints everything about [parl.GoError] 16 // - parl.GoError: type: *g0.GoError 17 // - err: pnet.InterfaceAddrs netInterface.Addrs route ip+net: invalid network interface at pnet.InterfaceAddrs()-interface.go:30 18 // - t: 2023-05-10 15:53:07.885969000-07:00 19 // - errContext: GeLocalChan 20 // - goroutine: 72_func:g5.(*Netlink).streamReaderThread()-netlink.go:156_cre:g5.(*Netlink).ReaderThread()-netlink.go:79 21 func GoErrorDump(goError parl.GoError) (s string) { 22 23 // check for nil 24 s = fmt.Sprintf("parl.GoError: type: %T", goError) 25 if goError == nil { 26 return // goError nil returns "parl.GoError: type: <nil>" 27 } 28 29 var threadInfo string 30 var goroutine = goError.Go() 31 if goroutine == nil { 32 threadInfo = "nil" 33 } else { 34 threadInfo = goroutine.ThreadInfo().String() 35 } 36 37 // GoError.err t errContext 38 s += fmt.Sprintf("\nerr: %s\nt: %s\nerrContext: %s\ngoroutine: %s\nerr trace: %s", 39 goError.Error(), 40 goError.Time().Format(parl.Rfc3339ns), 41 goError.ErrContext(), 42 threadInfo, 43 perrors.Long(goError.Err()), 44 ) 45 46 return 47 }