diff --git a/ibm/flex/structures.go b/ibm/flex/structures.go index 5f89a520a6..ce034b303c 100644 --- a/ibm/flex/structures.go +++ b/ibm/flex/structures.go @@ -3254,24 +3254,35 @@ func FlattenSatelliteZones(zones *schema.Set) []string { // error object type ServiceErrorResponse struct { - Message string - StatusCode int - Result interface{} + Message string + StatusCode int + XRequestId string `json:"X-Request-Id,omitempty"` + XCorrelationId string `json:"X-Correlation-Id,omitempty"` + Result interface{} } func BeautifyError(err error, response *core.DetailedResponse) *ServiceErrorResponse { var ( - statusCode int - result interface{} + statusCode int + result interface{} + xRequestId string + xCorrelationId string ) if response != nil { statusCode = response.StatusCode result = response.Result } + if err != nil { + xRequestId = response.Headers["X-Request-Id"][0] + xCorrelationId = response.Headers["X-Correlation-Id"][0] + } + return &ServiceErrorResponse{ - Message: err.Error(), - StatusCode: statusCode, - Result: result, + Message: err.Error(), + StatusCode: statusCode, + XRequestId: xRequestId, + XCorrelationId: xCorrelationId, + Result: result, } } diff --git a/ibm/service/vpc/resource_ibm_is_lb.go b/ibm/service/vpc/resource_ibm_is_lb.go index 66f6ebac1a..a245fdf6ce 100644 --- a/ibm/service/vpc/resource_ibm_is_lb.go +++ b/ibm/service/vpc/resource_ibm_is_lb.go @@ -460,7 +460,7 @@ func lbCreate(d *schema.ResourceData, meta interface{}, name, lbType, rg string, lb, response, err := sess.CreateLoadBalancer(options) if err != nil { - return fmt.Errorf("[ERROR] Error while creating Load Balancer err %s\n%s", err, response) + return fmt.Errorf("[ERROR] Error while creating Load Balancer err %s\n%s", flex.BeautifyError(err, response), response) } d.SetId(*lb.ID) log.Printf("[INFO] Load Balancer : %s", *lb.ID)