MCPcopy Index your code
hub / github.com/cockroachdb/errors / GetReportableStackTrace

Function GetReportableStackTrace

withstack/reportable.go:46–68  ·  view source on GitHub ↗

GetReportableStackTrace extracts a stack trace embedded in the given error in the format suitable for Sentry reporting. This supports: - errors generated by github.com/pkg/errors (either generated locally or after transfer through the network), - errors generated with WithStack() in this package, -

(err error)

Source from the content-addressed store, hash-verified

44// Note: Sentry wants the oldest call frame first, so
45// the entries are reversed in the result.
46func GetReportableStackTrace(err error) *ReportableStackTrace {
47 // If we have a stack trace in the style of github.com/pkg/errors
48 // (either from there or our own withStack), use it.
49 if st, ok := err.(errbase.StackTraceProvider); ok {
50 return convertPkgStack(st.StackTrace())
51 }
52
53 // If we have flattened a github.com/pkg/errors-style stack
54 // trace to a string, it will happen in the error's safe details
55 // and we need to parse it.
56 if sd, ok := err.(errbase.SafeDetailer); ok {
57 details := sd.SafeDetails()
58 if len(details) > 0 {
59 switch errbase.GetTypeKey(err) {
60 case pkgFundamental, pkgWithStackName, ourWithStackName:
61 return parsePrintedStack(details[0])
62 }
63 }
64 }
65
66 // No conversion available - no stack trace.
67 return nil
68}
69
70type frame = sentry.Frame
71

Callers 3

GetReportableStackTraceFunction · 0.92
checkStackTraceFunction · 0.92
BuildSentryReportFunction · 0.92

Calls 5

GetTypeKeyFunction · 0.92
convertPkgStackFunction · 0.85
parsePrintedStackFunction · 0.85
StackTraceMethod · 0.65
SafeDetailsMethod · 0.65

Tested by 1

checkStackTraceFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…