Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallerFunc ¶
CallerFunc returns the package and function name of the calling function that is not part of the errors package. The function name includes the line number, appended as :999.
If the caller cannot be determined, it returns "" for the package and function name and false.
func PanicTrace ¶
func PanicTrace() []byte
PanicTrace captures the stack trace at the point of panic. It is used to create a stack trace for a [PanicError] when it is recovered.
The trace is formatted to include only the lines after the panic line, which is determined by looking for the first line that starts with "panic(".
func StackTrace ¶
StackTrace returns a formatted stack trace. The trace skips a specified number of frames, allowing the caller to control how much of the stack is captured. It is intended that the caller will skip frames that are part of the errors package initialisation code, so that the stack trace does not include frames that are not relevant to the error being reported.
FUTURE: relying on the caller to skip frames is not ideal. It would be better to determine the appropriate cut-off using heuristics, similar to the `panicTrace` function. i.e. determine which of the initial frames are part of the `errors` initialisation code and skip those. This would likely require embedding some knowledge of the functions involved, but this is better than relying on the caller explicitly skipping a fixed number of frames.
Types ¶
This section is empty.