github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/api/cloudcontroller/ccerror/v2_unexpected_response_error.go (about)

     1  package ccerror
     2  
     3  import "fmt"
     4  
     5  // V2ErrorResponse represents a generic Cloud Controller V2 error response.
     6  type V2ErrorResponse struct {
     7  	Code        int    `json:"code"`
     8  	Description string `json:"description"`
     9  	ErrorCode   string `json:"error_code"`
    10  }
    11  
    12  // V2UnexpectedResponseError is returned when the client gets an error that has
    13  // not been accounted for.
    14  type V2UnexpectedResponseError struct {
    15  	V2ErrorResponse
    16  
    17  	RequestIDs   []string
    18  	ResponseCode int
    19  }
    20  
    21  func (e V2UnexpectedResponseError) Error() string {
    22  	message := fmt.Sprintf("Unexpected Response\nResponse code: %d\nCC code:       %d\nCC error code: %s", e.ResponseCode, e.Code, e.ErrorCode)
    23  	for _, id := range e.RequestIDs {
    24  		message = fmt.Sprintf("%s\nRequest ID:    %s", message, id)
    25  	}
    26  	return fmt.Sprintf("%s\nDescription:   %s", message, e.Description)
    27  }