github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/vendor_skip/nhooyr.io/websocket/internal/errd/wrap.go (about)

     1  package errd
     2  
     3  import (
     4  	"fmt"
     5  )
     6  
     7  // Wrap wraps err with fmt.Errorf if err is non nil.
     8  // Intended for use with defer and a named error return.
     9  // Inspired by https://github.com/golang/go/issues/32676.
    10  func Wrap(err *error, f string, v ...interface{}) {
    11  	if *err != nil {
    12  		*err = fmt.Errorf(f+": %w", append(v, *err)...)
    13  	}
    14  }