Wrapf returns an error annotating err with a stack trace at the point Wrapf is called, and the format specifier. It returns nil if given `err` is nil. Note that it does not lose the error code of wrapped error, as it inherits the error code from it.
(err error, format string, args ...any)
| 68 | // It returns nil if given `err` is nil. |
| 69 | // Note that it does not lose the error code of wrapped error, as it inherits the error code from it. |
| 70 | func Wrapf(err error, format string, args ...any) error { |
| 71 | if err == nil { |
| 72 | return nil |
| 73 | } |
| 74 | return &Error{ |
| 75 | error: err, |
| 76 | stack: callers(), |
| 77 | text: format, |
| 78 | args: args, |
| 79 | code: Code(err), |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // WrapSkip wraps error with text. It returns nil if given err is nil. |
| 84 | // The parameter `skip` specifies the stack callers skipped amount. |
searching dependent graphs…