github.com/haraldrudell/parl@v0.4.176/perrors/errp.go (about)

     1  /*
     2  © 2020–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/)
     3  ISC License
     4  */
     5  
     6  package perrors
     7  
     8  // error116.Errp returns a function that updates an an error pointer value
     9  // with additional associated errors on subsequent invocations.
    10  // It is intended to be used with parl.Recover().
    11  // for a thread-safe version, use error116.ParlError
    12  func Errp(errp *error) func(e error) {
    13  	if errp == nil {
    14  		panic("Errp with nil argument")
    15  	}
    16  	return func(e error) {
    17  		*errp = AppendError(*errp, e)
    18  	}
    19  }