Skip to content

Commit

Permalink
Add %w error directive change
Browse files Browse the repository at this point in the history
  • Loading branch information
ismirlia authored and yussufsh committed Sep 25, 2023
1 parent 6b71419 commit 4fe52aa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions clients/instance/ibm-pi-sap-instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (f *IBMPISAPInstanceClient) Create(body *models.SAPCreate) (*models.PVMInst
WithCloudInstanceID(f.cloudInstanceID).WithBody(body)
postok, postcreated, postAccepted, err := f.session.Power.PCloudsap.PcloudSapPost(params, f.session.AuthInfo(f.cloudInstanceID))
if err != nil {
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to Create SAP Instance: %v", err))
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to Create SAP Instance: %w", err))
}
if postok != nil && len(postok.Payload) > 0 {
return &postok.Payload, nil
Expand All @@ -56,7 +56,7 @@ func (f *IBMPISAPInstanceClient) GetSAPProfile(id string) (*models.SAPProfile, e
WithCloudInstanceID(f.cloudInstanceID).WithSapProfileID(id)
resp, err := f.session.Power.PCloudsap.PcloudSapGet(params, f.session.AuthInfo(f.cloudInstanceID))
if err != nil {
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to get sap profile %s : %v", id, err))
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to get sap profile %s : %w", id, err))
}
if resp == nil || resp.Payload == nil {
return nil, fmt.Errorf("failed to get sap profile %s", id)
Expand All @@ -74,7 +74,7 @@ func (f *IBMPISAPInstanceClient) GetAllSAPProfiles(cloudInstanceID string) (*mod
WithCloudInstanceID(f.cloudInstanceID)
resp, err := f.session.Power.PCloudsap.PcloudSapGetall(params, f.session.AuthInfo(f.cloudInstanceID))
if err != nil {
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to get all sap profiles for power instance %s: %v", cloudInstanceID, err))
return nil, ibmpisession.SDKFailWithAPIError(err, fmt.Errorf("failed to get all sap profiles for power instance %s: %w", cloudInstanceID, err))
}
if resp == nil || resp.Payload == nil {
return nil, fmt.Errorf("failed to get all sap profiles for power instance %s", cloudInstanceID)
Expand Down
2 changes: 1 addition & 1 deletion ibmpisession/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func costructRegionFromZone(zone string) string {
func SDKFailWithAPIError(err error, origErr error) error {
if apierr, ok := err.(*runtime.APIError); ok {
if apierr.Code >= 500 {
return fmt.Errorf("error: %v The server has encountered an unexpected error and is unable to fulfill the request", err)
return fmt.Errorf("error: %w The server has encountered an unexpected error and is unable to fulfill the request", err)
}
}
return origErr
Expand Down

0 comments on commit 4fe52aa

Please sign in to comment.