Skip to content

Commit 87968fb

Browse files
committed
Improved errors + updated SDK
1 parent 3f8542f commit 87968fb

14 files changed

+43
-15
lines changed

src/Resources/ResourceManager/Implementation/DeploymentStacks/NewAzResourceGroupDeploymentStack.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@ public override void ExecuteCmdlet()
184184
}
185185
catch (Exception ex)
186186
{
187-
WriteExceptionError(ex);
187+
if (ex is DeploymentStacksErrorException dex)
188+
throw new PSArgumentException(dex.Message + " : " + dex.Body.Error.Code + " : " + dex.Body.Error.Message);
189+
else
190+
WriteExceptionError(ex);
188191
}
189192
}
190193

src/Resources/ResourceManager/Implementation/DeploymentStacks/NewAzSubscriptionDeploymentStack.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ public override void ExecuteCmdlet()
182182
}
183183
catch (Exception ex)
184184
{
185-
WriteExceptionError(ex);
185+
if (ex is DeploymentStacksErrorException dex)
186+
throw new PSArgumentException(dex.Message + " : " + dex.Body.Error.Code + " : " + dex.Body.Error.Message);
187+
else
188+
WriteExceptionError(ex);
186189
}
187190
}
188191

src/Resources/ResourceManager/Implementation/DeploymentStacks/RemoveAzResourceGroupDeploymentStack.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
1616
{
1717
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
18+
using Microsoft.Azure.Management.ResourceManager.Models;
1819
using System;
1920
using System.Collections.Generic;
2021
using System.Management.Automation;
@@ -78,7 +79,10 @@ public override void ExecuteCmdlet()
7879
}
7980
catch (Exception ex)
8081
{
81-
WriteExceptionError(ex);
82+
if (ex is DeploymentStacksErrorException dex)
83+
throw new PSArgumentException(dex.Message + " : " + dex.Body.Error.Code + " : " + dex.Body.Error.Message);
84+
else
85+
WriteExceptionError(ex);
8286
}
8387
}
8488

src/Resources/ResourceManager/Implementation/DeploymentStacks/RemoveAzResourceGroupDeploymentStackSnapshot.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
1616
{
1717
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
18+
using Microsoft.Azure.Management.ResourceManager.Models;
1819
using System;
1920
using System.Collections.Generic;
2021
using System.Management.Automation;
@@ -89,7 +90,10 @@ public override void ExecuteCmdlet()
8990
}
9091
catch (Exception ex)
9192
{
92-
WriteExceptionError(ex);
93+
if (ex is DeploymentStacksErrorException dex)
94+
throw new PSArgumentException(dex.Message + " : " + dex.Body.Error.Code + " : " + dex.Body.Error.Message);
95+
else
96+
WriteExceptionError(ex);
9397
}
9498
}
9599

src/Resources/ResourceManager/Implementation/DeploymentStacks/RemoveAzSubscriptionDeploymentStack.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
1616
{
1717
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
18+
using Microsoft.Azure.Management.ResourceManager.Models;
1819
using System;
1920
using System.Collections.Generic;
2021
using System.Management.Automation;
@@ -68,7 +69,10 @@ public override void ExecuteCmdlet()
6869
}
6970
catch (Exception ex)
7071
{
71-
WriteExceptionError(ex);
72+
if (ex is DeploymentStacksErrorException dex)
73+
throw new PSArgumentException(dex.Message + " : " + dex.Body.Error.Code + " : " + dex.Body.Error.Message);
74+
else
75+
WriteExceptionError(ex);
7276
}
7377
}
7478

src/Resources/ResourceManager/Implementation/DeploymentStacks/RemoveAzSubscriptionDeploymentStackSnapshot.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
1616
{
1717
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
18+
using Microsoft.Azure.Management.ResourceManager.Models;
1819
using System;
1920
using System.Collections.Generic;
2021
using System.Management.Automation;
@@ -83,7 +84,10 @@ public override void ExecuteCmdlet()
8384
}
8485
catch (Exception ex)
8586
{
86-
WriteExceptionError(ex);
87+
if (ex is DeploymentStacksErrorException dex)
88+
throw new PSArgumentException(dex.Message + " : " + dex.Body.Error.Code + " : " + dex.Body.Error.Message);
89+
else
90+
WriteExceptionError(ex);
8791
}
8892
}
8993

src/Resources/ResourceManager/Implementation/DeploymentStacks/SetAzResourceGroupDeploymentStack.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,10 @@ public override void ExecuteCmdlet()
189189
}
190190
catch (Exception ex)
191191
{
192-
WriteExceptionError(ex);
192+
if (ex is DeploymentStacksErrorException dex)
193+
throw new PSArgumentException(dex.Message + " : " + dex.Body.Error.Code + " : " + dex.Body.Error.Message);
194+
else
195+
WriteExceptionError(ex);
193196
}
194197
}
195198

src/Resources/ResourceManager/Implementation/DeploymentStacks/SetAzSubscriptionDeploymentStack.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,10 @@ public override void ExecuteCmdlet()
187187
}
188188
catch (Exception ex)
189189
{
190-
WriteExceptionError(ex);
190+
if (ex is DeploymentStacksErrorException dex)
191+
throw new PSArgumentException(dex.Message + " : " + dex.Body.Error.Code + " : " + dex.Body.Error.Message);
192+
else
193+
WriteExceptionError(ex);
191194
}
192195
}
193196

src/Resources/ResourceManager/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
[assembly: ComVisible(false)]
2626
[assembly: CLSCompliant(false)]
2727
[assembly: Guid("e8f34267-c461-4eae-b156-5f3528553d10")]
28-
[assembly: AssemblyVersion("4.2.0")]
29-
[assembly: AssemblyFileVersion("4.2.0")]
28+
[assembly: AssemblyVersion("4.2.8")]
29+
[assembly: AssemblyFileVersion("4.2.8")]
3030
#if !SIGN
3131
[assembly: InternalsVisibleTo("Microsoft.Azure.PowerShell.Cmdlets.Resources.Test")]
3232
[assembly: InternalsVisibleTo("Microsoft.Azure.PowerShell.Cmdlets.MachineLearning.Test")]

src/Resources/ResourceManager/ResourceManager.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<ItemGroup>
1515
<PackageReference Include="AutoMapper" Version="6.2.2" />
16-
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="3.14.3-stacks" />
16+
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="3.14.4-stacks" />
1717
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
1818
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.2.0" />
1919
</ItemGroup>

src/Resources/Resources.Test/Resources.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</ItemGroup>
3333

3434
<ItemGroup>
35-
<PackageReference Update="Microsoft.Azure.Management.ResourceManager" Version="3.14.3-stacks" />
35+
<PackageReference Update="Microsoft.Azure.Management.ResourceManager" Version="3.14.4-stacks" />
3636
</ItemGroup>
3737
<ItemGroup>
3838
<PackageReference Include="FluentAssertions" Version="5.9.0" />

src/Resources/Resources/Az.Resources.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# RootModule = ''
1313

1414
# Version number of this module.
15-
ModuleVersion = '4.2.0'
15+
ModuleVersion = '4.2.8'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = 'Core', 'Desktop'

src/Resources/Resources/Resources.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageReference Include="Microsoft.Azure.Graph.RBAC" Version="3.8.0-preview" />
1515
<PackageReference Include="Microsoft.Azure.Management.Authorization" Version="2.12.0-preview" />
1616
<PackageReference Include="Microsoft.Azure.Management.ManagementGroups" Version="1.1.1-preview" />
17-
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="3.14.3-stacks" />
17+
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="3.14.4-stacks" />
1818
</ItemGroup>
1919

2020
<ItemGroup>

src/Resources/Resources/Resources.format.ps1xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@
565565
<ItemSelectionCondition>
566566
<ScriptBlock>$_.error -ne $null</ScriptBlock>
567567
</ItemSelectionCondition>
568-
<ScriptBlock>$_.error.Message</ScriptBlock>
568+
<ScriptBlock>$e=$_.error; while($e.Details -ne $null){$e = $e.Details[0]}$e.Code + " - " +$e.Message</ScriptBlock>
569569
</ListItem>
570570
</ListItems>
571571
</ListEntry>

0 commit comments

Comments
 (0)