Skip to content

Commit

Permalink
Fix to handle crash for cloudshell
Browse files Browse the repository at this point in the history
  • Loading branch information
hkantare authored and kavya498 committed May 17, 2024
1 parent ef175f7 commit e590793
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func resourceIBMCloudShellAccountSettingsCreate(context context.Context, d *sche
}

accountSettings, response, err := ibmCloudShellClient.UpdateAccountSettingsWithContext(context, updateAccountSettingsOptions)
if err != nil {
if err != nil || accountSettings == nil {
log.Printf("[DEBUG] UpdateAccountSettingsWithContext failed %s\n%s", err, response)
return diag.FromErr(fmt.Errorf("UpdateAccountSettingsWithContext failed %s\n%s", err, response))
}
Expand Down Expand Up @@ -211,7 +211,7 @@ func resourceIBMCloudShellAccountSettingsRead(context context.Context, d *schema
getAccountSettingsOptions.SetAccountID(strings.TrimPrefix(d.Id(), "ac-"))

accountSettings, response, err := ibmCloudShellClient.GetAccountSettingsWithContext(context, getAccountSettingsOptions)
if err != nil {
if err != nil || accountSettings == nil {
if response != nil && response.StatusCode == 404 {
d.SetId("")
return nil
Expand Down Expand Up @@ -345,8 +345,8 @@ func resourceIBMCloudShellAccountSettingsUpdate(context context.Context, d *sche
}

if hasChange {
_, response, err := ibmCloudShellClient.UpdateAccountSettingsWithContext(context, updateAccountSettingsOptions)
if err != nil {
accountSettings, response, err := ibmCloudShellClient.UpdateAccountSettingsWithContext(context, updateAccountSettingsOptions)
if err != nil || accountSettings == nil {
log.Printf("[DEBUG] UpdateAccountSettingsWithContext failed %s\n%s", err, response)
return diag.FromErr(fmt.Errorf("UpdateAccountSettingsWithContext failed %s\n%s", err, response))
}
Expand Down

0 comments on commit e590793

Please sign in to comment.