Package tb exposes some handy traceback functionality buried in the runtime.
It can also be used to provide context to errors reducing the temptation to panic carelessly, just to get stack information.
The theory is that most errors that are created with the fmt.Errorf style are likely to be rare, but require more context to debug properly. The additional cost of computing a stack trace is therefore negligible.
Stack is taken from runtime/debug.go calldepth is the number of (bottommost) frames to skip.
StackError represents an error along with a stack trace.