You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
326 B
15 lines
326 B
3 years ago
|
package errd
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
// Wrap wraps err with fmt.Errorf if err is non nil.
|
||
|
// Intended for use with defer and a named error return.
|
||
|
// Inspired by https://github.com/golang/go/issues/32676.
|
||
|
func Wrap(err *error, f string, v ...interface{}) {
|
||
|
if *err != nil {
|
||
|
*err = fmt.Errorf(f+": %w", append(v, *err)...)
|
||
|
}
|
||
|
}
|