NewWrappedError creates a new [WrappedError] with the given error and options. It wraps the provided even if it already is an [WrappedError] and always creates a new context. To avoid double wrapping and reuse existing context, use [Wrap] instead.
(err error, stackSkip int, opts ...Option)
| 16 | // creates a new context. |
| 17 | // To avoid double wrapping and reuse existing context, use [Wrap] instead. |
| 18 | func NewWrappedError(err error, stackSkip int, opts ...Option) *WrappedError { |
| 19 | return &WrappedError{ |
| 20 | error: err, |
| 21 | ErrorContext: newErrorContext(stackSkip+1, opts...), |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | // Wrap creates a new [WrappedError] with the given error and options. |
| 26 | // It gets the stack trace from the call site. |
no test coverage detected