WrapPrefix makes an Error from the given value. If that value is already an error then it will be used directly, if not, it will be passed to fmt.Errorf("%v"). The prefix parameter is used to add a prefix to the error message when calling Error(). The skip parameter indicates how far up the stack to
(e interface{}, prefix string, skip int)
| 121 | // up the stack to start the stacktrace. 0 is from the current call, |
| 122 | // 1 from its caller, etc. |
| 123 | func WrapPrefix(e interface{}, prefix string, skip int) *Error { |
| 124 | if e == nil { |
| 125 | return nil |
| 126 | } |
| 127 | |
| 128 | err := Wrap(e, 1+skip) |
| 129 | |
| 130 | if err.prefix != "" { |
| 131 | prefix = fmt.Sprintf("%s: %s", prefix, err.prefix) |
| 132 | } |
| 133 | |
| 134 | return &Error{ |
| 135 | Err: err.Err, |
| 136 | stack: err.stack, |
| 137 | prefix: prefix, |
| 138 | } |
| 139 | |
| 140 | } |
| 141 | |
| 142 | // Errorf creates a new error with the given message. You can use it |
| 143 | // as a drop-in replacement for fmt.Errorf() to provide descriptive |
searching dependent graphs…