github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/client/allocrunner/taskrunner/getter/error.go (about)

     1  package getter
     2  
     3  // Error is a RecoverableError used to include the URL along with the underlying
     4  // fetching error.
     5  type Error struct {
     6  	URL         string
     7  	Err         error
     8  	Recoverable bool
     9  }
    10  
    11  func (e *Error) Error() string {
    12  	if e == nil || e.Err == nil {
    13  		return "<nil>"
    14  	}
    15  	return e.Err.Error()
    16  }
    17  
    18  func (e *Error) IsRecoverable() bool {
    19  	return e.Recoverable
    20  }
    21  
    22  func (e *Error) Equal(o *Error) bool {
    23  	if e == nil || o == nil {
    24  		return e == o
    25  	}
    26  
    27  	switch {
    28  	case e.URL != o.URL:
    29  		return false
    30  	case e.Recoverable != o.Recoverable:
    31  		return false
    32  	case e.Error() != o.Error():
    33  		return false
    34  	default:
    35  		return true
    36  	}
    37  }