github.com/operator-framework/operator-lifecycle-manager@v0.30.0/pkg/lib/scoped/error.go (about)

     1  package scoped
     2  
     3  // operatorGroupError is an error type returned by the service account querier when
     4  // there is an invalid operatorGroup (zero groups, multiple groups, non-existent service account)
     5  type operatorGroupError struct {
     6  	s string
     7  }
     8  
     9  func NewOperatorGroupError(s string) error {
    10  	return operatorGroupError{s: s}
    11  }
    12  
    13  func (e operatorGroupError) Error() string {
    14  	return e.s
    15  }
    16  
    17  func (e operatorGroupError) IsOperatorGroupError() bool {
    18  	return true
    19  }
    20  
    21  // IsOperatorGroupError checks if an error is an operator group error
    22  // This lets us classify multiple errors as operatorGroupError without
    23  // defining and checking all the specific error value types
    24  func IsOperatorGroupError(err error) bool {
    25  	type operatorGroupError interface {
    26  		IsOperatorGroupError() bool
    27  	}
    28  	ogErr, ok := err.(operatorGroupError)
    29  	return ok && ogErr.IsOperatorGroupError()
    30  }