Skip to content

Commit

Permalink
For Get and Remove - return inner exception body message
Browse files Browse the repository at this point in the history
  • Loading branch information
rebecca-makar committed Mar 11, 2020
1 parent ad70c97 commit d48d6ef
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
13 changes: 11 additions & 2 deletions src/StorageCache/HPCCache/Commands/GetAzHpcCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ namespace Microsoft.Azure.Commands.HPCCache
{
using System.Management.Automation;
using Microsoft.Azure.Management.StorageCache;
using Microsoft.Azure.Management.StorageCache.Models;
using Microsoft.Azure.PowerShell.Cmdlets.HPCCache.Models;
using Microsoft.Rest.Azure;

/// <summary>
/// Get Cache / RG specific cache(s) / subscription wide caches.
Expand Down Expand Up @@ -45,8 +47,15 @@ public override void ExecuteCmdlet()
{
if (!string.IsNullOrEmpty(this.CacheName))
{
var singleCache = this.HpcCacheClient.Caches.Get(this.ResourceGroupName, this.CacheName);
this.WriteObject(new PSHPCCache(singleCache), true);
try
{
var singleCache = this.HpcCacheClient.Caches.Get(this.ResourceGroupName, this.CacheName);
this.WriteObject(new PSHPCCache(singleCache), true);
}
catch (CloudErrorException ex)
{
throw new CloudException(string.Format("Exception: {0}", ex.Body.Error.Message));
}
}
else
{
Expand Down
13 changes: 11 additions & 2 deletions src/StorageCache/HPCCache/Commands/GetAzHpcCacheStorageTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ namespace Microsoft.Azure.Commands.HPCCache
{
using System.Management.Automation;
using Microsoft.Azure.Management.StorageCache;
using Microsoft.Azure.Management.StorageCache.Models;
using Microsoft.Azure.PowerShell.Cmdlets.HPCCache.Models;
using Microsoft.Rest.Azure;

/// <summary>
/// Get StorageTargets on Cache.
Expand Down Expand Up @@ -54,8 +56,15 @@ public override void ExecuteCmdlet()
{
if (!string.IsNullOrEmpty(this.StorageTargetName))
{
var singleST = this.HpcCacheClient.StorageTargets.Get(this.ResourceGroupName, this.CacheName, this.StorageTargetName);
this.WriteObject(new PSHpcStorageTarget(singleST), true);
try
{
var singleST = this.HpcCacheClient.StorageTargets.Get(this.ResourceGroupName, this.CacheName, this.StorageTargetName);
this.WriteObject(new PSHpcStorageTarget(singleST), true);
}
catch (CloudErrorException ex)
{
throw new CloudException(string.Format("Exception: {0}", ex.Body.Error.Message));
}
}
else
{
Expand Down
15 changes: 12 additions & 3 deletions src/StorageCache/HPCCache/Commands/RemoveAzHpcCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ namespace Microsoft.Azure.Commands.HPCCache
using System.Management.Automation;
using Microsoft.Azure.Commands.HPCCache.Properties;
using Microsoft.Azure.Management.StorageCache;
using Microsoft.Azure.Management.StorageCache.Models;
using Microsoft.Azure.PowerShell.Cmdlets.HPCCache.Models;
using Microsoft.Rest.Azure;

/// <summary>
/// Remove HPC Cache.
Expand Down Expand Up @@ -69,10 +71,17 @@ public override void ExecuteCmdlet()
this.CacheName,
() =>
{
this.HpcCacheClient.Caches.Delete(this.ResourceGroupName, this.CacheName);
if (this.PassThru)
try
{
this.WriteObject(true);
this.HpcCacheClient.Caches.Delete(this.ResourceGroupName, this.CacheName);
if (this.PassThru)
{
this.WriteObject(true);
}
}
catch (CloudErrorException ex)
{
throw new CloudException(string.Format("Exception: {0}", ex.Body.Error.Message));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ namespace Microsoft.Azure.Commands.HPCCache
using System.Management.Automation;
using Microsoft.Azure.Commands.HPCCache.Properties;
using Microsoft.Azure.Management.StorageCache;
using Microsoft.Azure.Management.StorageCache.Models;
using Microsoft.Azure.PowerShell.Cmdlets.HPCCache.Models;
using Microsoft.Rest.Azure;

/// <summary>
/// Remove Storage Target.
Expand Down Expand Up @@ -76,10 +78,17 @@ public override void ExecuteCmdlet()
this.CacheName,
() =>
{
this.HpcCacheClient.StorageTargets.Delete(this.ResourceGroupName, this.CacheName, this.StorageTargetName);
if (this.PassThru)
try
{
this.WriteObject(true);
this.HpcCacheClient.StorageTargets.Delete(this.ResourceGroupName, this.CacheName, this.StorageTargetName);
if (this.PassThru)
{
this.WriteObject(true);
}
}
catch (CloudErrorException ex)
{
throw new CloudException(string.Format("Exception: {0}", ex.Body.Error.Message));
}
});
}
Expand Down

0 comments on commit d48d6ef

Please sign in to comment.