github.com/swisscom/cloudfoundry-cli@v7.1.0+incompatible/api/cloudcontroller/ccerror/v3_unexpected_response_error.go (about) 1 package ccerror 2 3 import ( 4 "fmt" 5 "strings" 6 ) 7 8 // V3ErrorResponse represents a generic Cloud Controller V3 error response. 9 type V3ErrorResponse struct { 10 Errors []V3Error `json:"errors"` 11 } 12 13 // V3UnexpectedResponseError is returned when the client gets an error that has 14 // not been accounted for. 15 type V3UnexpectedResponseError struct { 16 V3ErrorResponse 17 18 ResponseCode int 19 RequestIDs []string 20 } 21 22 func (e V3UnexpectedResponseError) Error() string { 23 messages := []string{ 24 "Unexpected Response", 25 fmt.Sprintf("Response Code: %d", e.ResponseCode), 26 } 27 28 for _, id := range e.RequestIDs { 29 messages = append(messages, fmt.Sprintf("Request ID: %s", id)) 30 } 31 32 for _, ccError := range e.V3ErrorResponse.Errors { 33 messages = append(messages, fmt.Sprintf("Code: %d, Title: %s, Detail: %s", ccError.Code, ccError.Title, ccError.Detail)) 34 } 35 36 return strings.Join(messages, "\n") 37 }