github.com/dcarley/cf-cli@v6.24.1-0.20170220111324-4225ff346898+incompatible/api/uaa/errors.go (about)

     1  package uaa
     2  
     3  import "fmt"
     4  
     5  // RawHTTPStatusError represents any response with a 4xx or 5xx status code.
     6  type RawHTTPStatusError struct {
     7  	StatusCode  int
     8  	RawResponse []byte
     9  }
    10  
    11  func (r RawHTTPStatusError) Error() string {
    12  	return fmt.Sprintf("Error Code: %d\nRaw Response: %s", r.StatusCode, r.RawResponse)
    13  }
    14  
    15  // UAAErrorResponse represents a generic UAA error response.
    16  type UAAErrorResponse struct {
    17  	Type        string `json:"error"`
    18  	Description string `json:"error_description"`
    19  }
    20  
    21  func (e UAAErrorResponse) Error() string {
    22  	return fmt.Sprintf("Error Type: %s\nDescription: %s", e.Type, e.Description)
    23  }
    24  
    25  // ConflictError is returned when the response status code is 409. It
    26  // represents when there is a conflict in the state of the requested resource.
    27  type ConflictError struct {
    28  	Message string
    29  }
    30  
    31  func (e ConflictError) Error() string {
    32  	return e.Message
    33  }
    34  
    35  // UnverifiedServerError replaces x509.UnknownAuthorityError when the server
    36  // has SSL but the client is unable to verify it's certificate
    37  type UnverifiedServerError struct {
    38  	URL string
    39  }
    40  
    41  func (e UnverifiedServerError) Error() string {
    42  	return "x509: certificate signed by unknown authority"
    43  }
    44  
    45  // RequestError represents a generic error encountered while performing the
    46  // HTTP request. This generic error occurs before a HTTP response is obtained.
    47  type RequestError struct {
    48  	Err error
    49  }
    50  
    51  func (e RequestError) Error() string {
    52  	return e.Err.Error()
    53  }
    54  
    55  // InvalidAuthTokenError is returned when the client has an invalid
    56  // authorization header.
    57  type InvalidAuthTokenError struct {
    58  	Message string
    59  }
    60  
    61  func (e InvalidAuthTokenError) Error() string {
    62  	return e.Message
    63  }
    64  
    65  // InsufficientScopeError is returned when the client has insufficient scope
    66  type InsufficientScopeError struct {
    67  	Message string
    68  }
    69  
    70  func (e InsufficientScopeError) Error() string {
    71  	return e.Message
    72  }
    73  
    74  // InvalidSCIMResourceError is returned usually when the client tries to create an inproperly formatted username
    75  type InvalidSCIMResourceError struct {
    76  	Message string
    77  }
    78  
    79  func (e InvalidSCIMResourceError) Error() string {
    80  	return e.Message
    81  }