github.com/xraypb/Xray-core@v1.8.1/app/observatory/explainErrors.go (about)

     1  package observatory
     2  
     3  import "github.com/xraypb/Xray-core/common/errors"
     4  
     5  type errorCollector struct {
     6  	errors *errors.Error
     7  }
     8  
     9  func (e *errorCollector) SubmitError(err error) {
    10  	if e.errors == nil {
    11  		e.errors = newError("underlying connection error").Base(err)
    12  		return
    13  	}
    14  	e.errors = e.errors.Base(newError("underlying connection error").Base(err))
    15  }
    16  
    17  func newErrorCollector() *errorCollector {
    18  	return &errorCollector{}
    19  }
    20  
    21  func (e *errorCollector) UnderlyingError() error {
    22  	if e.errors == nil {
    23  		return newError("failed to produce report")
    24  	}
    25  	return e.errors
    26  }