github.com/lukasheimann/cloudfoundrycli@v7.1.0+incompatible/command/translatableerror/unauthorized_error.go (about)

     1  package translatableerror
     2  
     3  const (
     4  	BadCredentialMessage   = "Bad credentials"
     5  	InvalidOriginMessage   = "The origin provided in the login hint is invalid."
     6  	UnmatchedOriginMessage = "The origin provided in the login_hint does not match an active Identity Provider, that supports password grant."
     7  )
     8  
     9  type UnauthorizedError struct {
    10  	Message string
    11  }
    12  
    13  func (e UnauthorizedError) Error() string {
    14  	switch e.Message {
    15  	case BadCredentialMessage:
    16  		return "Credentials were rejected, please try again."
    17  	case InvalidOriginMessage, UnmatchedOriginMessage:
    18  		return "The origin provided is invalid."
    19  	default:
    20  		return e.Message
    21  	}
    22  }
    23  
    24  func (e UnauthorizedError) Translate(translate func(string, ...interface{}) string) string {
    25  	return translate(e.Error())
    26  }