Wrap adds information about the program counter of the caller to the error. This is intended to be used at all return points in a function. If err is nil, Wrap returns nil. go:noinline so caller's PC is saved in the stack frame for asm GetCaller.
(err error)
| 10 | // |
| 11 | //go:noinline so caller's PC is saved in the stack frame for asm GetCaller. |
| 12 | func Wrap(err error) error { |
| 13 | if err == nil { |
| 14 | return nil |
| 15 | } |
| 16 | |
| 17 | return wrap(err, pc.GetCaller()) |
| 18 | } |
| 19 | |
| 20 | // Wrap2 is used to [Wrap] the last error return when returning 2 values. |
| 21 | // This is useful when returning multiple returns from a function call directly: |