WrapWithDepthf is like Wrapf except the depth to capture the stack trace is configurable. The the doc of `Wrapf()` for more details.
(depth int, err error, format string, args ...interface{})
| 141 | // trace is configurable. |
| 142 | // The the doc of `Wrapf()` for more details. |
| 143 | func WrapWithDepthf(depth int, err error, format string, args ...interface{}) error { |
| 144 | if err == nil { |
| 145 | return nil |
| 146 | } |
| 147 | var errRefs []error |
| 148 | for _, a := range args { |
| 149 | if e, ok := a.(error); ok { |
| 150 | errRefs = append(errRefs, e) |
| 151 | } |
| 152 | } |
| 153 | if format != "" || len(args) > 0 { |
| 154 | err = WithMessagef(err, format, args...) |
| 155 | } |
| 156 | for _, e := range errRefs { |
| 157 | err = secondary.WithSecondaryError(err, e) |
| 158 | } |
| 159 | err = withstack.WithStackDepth(err, depth+1) |
| 160 | return err |
| 161 | } |
| 162 | |
| 163 | // JoinWithDepth constructs a Join error with the provided list of |
| 164 | // errors as arguments, and wraps it in a `WithStackDepth` to capture a |
no test coverage detected
searching dependent graphs…