Skip to content

Commit 03e323a

Browse files
committed
Merge pull request #39 from AzCiS/sanmah
Handling 404 error in powershell
2 parents 176f2ee + 3ebf275 commit 03e323a

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

src/ServiceManagement/StorSimple/Commands.StorSimple/Properties/Resources.Designer.cs

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ServiceManagement/StorSimple/Commands.StorSimple/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,9 @@ a special character</value>
529529
<data name="SetAzureStorSimpleDeviceNoSettingsProvided" xml:space="preserve">
530530
<value>No settings were provided for updating device details.</value>
531531
</data>
532+
<data name="NotFoundWebExceptionMessage" xml:space="preserve">
533+
<value>One or more inputs passed is wrong or the cmdlet that you are trying to use is not available.</value>
534+
</data>
532535
<data name="EncryptionKeyNotAcceptableMessage" xml:space="preserve">
533536
<value>Please provide an encryption key consisting of printable ASCII characters</value>
534537
</data>

src/ServiceManagement/StorSimple/Commands.StorSimple/StorSimpleCmdletBase.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,19 @@ internal virtual void HandleException(Exception exception)
145145
var response = cloudEx.Response;
146146
try
147147
{
148-
XDocument xDoc = XDocument.Parse(response.Content);
149-
StripNamespaces(xDoc);
150-
string cloudErrorCode = xDoc.Descendants("ErrorCode").FirstOrDefault().Value;
151-
WriteVerbose(string.Format(Resources.CloudExceptionMessage, cloudErrorCode));
148+
if (response.StatusCode == HttpStatusCode.NotFound)
149+
{
150+
var notAvailableException = new Exception(Resources.NotFoundWebExceptionMessage);
151+
errorRecord = new ErrorRecord(notAvailableException, string.Empty, ErrorCategory.InvalidOperation, null);
152+
break;
153+
}
154+
else
155+
{
156+
XDocument xDoc = XDocument.Parse(response.Content);
157+
StripNamespaces(xDoc);
158+
string cloudErrorCode = xDoc.Descendants("ErrorCode").FirstOrDefault().Value;
159+
WriteVerbose(string.Format(Resources.CloudExceptionMessage, cloudErrorCode));
160+
}
152161
}
153162
catch (Exception)
154163
{
@@ -380,7 +389,7 @@ public bool IsDeviceConfigurationCompleteForDevice(DeviceDetails details)
380389
}
381390
return data0Configured;
382391
}
383-
392+
384393
/// <summary>
385394
/// this method verifies that the devicename parameter specified is completely configured
386395
/// most operations are not allowed on a non-configured device

0 commit comments

Comments
 (0)