WithStackDepth annotates err with a stack trace starting from the given call depth. The value zero identifies the caller of WithStackDepth itself. See the documentation of WithStack() for more details.
(err error, depth int)
| 44 | // of WithStackDepth itself. |
| 45 | // See the documentation of WithStack() for more details. |
| 46 | func WithStackDepth(err error, depth int) error { |
| 47 | if err == nil { |
| 48 | return nil |
| 49 | } |
| 50 | return &withStack{cause: err, stack: callers(depth + 1)} |
| 51 | } |
| 52 | |
| 53 | type withStack struct { |
| 54 | cause error |
searching dependent graphs…