New 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 stacktrace will point to the line of code that called New.
(e interface{})
| 69 | // fmt.Errorf("%v"). The stacktrace will point to the line of code that |
| 70 | // called New. |
| 71 | func New(e interface{}) *Error { |
| 72 | var err error |
| 73 | |
| 74 | switch e := e.(type) { |
| 75 | case error: |
| 76 | err = e |
| 77 | default: |
| 78 | err = fmt.Errorf("%v", e) |
| 79 | } |
| 80 | |
| 81 | stack := make([]uintptr, MaxStackDepth) |
| 82 | length := runtime.Callers(2, stack[:]) |
| 83 | return &Error{ |
| 84 | Err: err, |
| 85 | stack: stack[:length], |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | // Wrap makes an Error from the given value. If that value is already an |
| 90 | // error then it will be used directly, if not, it will be passed to |