| 1 | package culpa |
| 2 | |
| 3 | import "go.bigb.es/auxilia/stacktrace" |
| 4 | |
| 5 | // StacktraceDetail carries a captured stack trace. |
| 6 | // It uses MergeCombine so that traces from multiple wrap layers accumulate. |
| 7 | type StacktraceDetail struct{ Trace stacktrace.Trace } |
| 8 | |
| 9 | // MergeStrategy implements MergeStrategyProvider. |
| 10 | func (StacktraceDetail) MergeStrategy() MergeStrategy { return MergeCombine } |
| 11 | |
| 12 | // withStacktrace captures a stack trace and attaches it to the error. |
| 13 | // Skips 2 frames: withStacktrace itself + the public caller (Wrap/Wrapf/NewXxx). |
| 14 | func withStacktrace(err error) error { |
| 15 | return WithDetail(err, StacktraceDetail{Trace: stacktrace.Capture(2)}) |
| 16 | } |
| 17 | |