code: func (s *Segment) RecordError(e error) {
  	xerr := exceptionData(e)
  
  	s.Lock()
  	defer s.Unlock()
  
  	// set Error to indicate an internal error due to service being unreachable, etc.
  	// otherwise if a response was received then the status will determine Error vs. Fault.
  	//
  	// first check if the other flags have already been set in case these methods are being
  	// called directly instead of using xray.WrapClient(), etc.
  	if !(s.Fault || s.Throttle) {
  		s.Error = true
  	}
  	if s.Cause == nil {
  		wd, _ := os.Getwd()
  		s.Cause = &Cause{WorkingDirectory: wd}
  	}
  	s.Cause.Exceptions = append(s.Cause.Exceptions, xerr)
  	p := s.Parent
  	for p != nil {
  		if p.Cause == nil {
  			p.Cause = &Cause{ID: s.ID}
  		}
  		p = p.Parent
  	}
  }
docs: // RecordError traces an error. The client may also want to initialize the
  // fault field of s.
  //
  // The trace contains a stack trace and a cause for the error if the argument
  // was created using one of the New, Errorf, Wrap or Wrapf functions of the
  // github.com/pkg/errors package. Otherwise the Stack and Cause fields are empty.