Skip to content

Commit 26a0433

Browse files
author
ramyapri
committed
Code review fix - Changing specific exceptions to generic ones
1 parent 78b6f4c commit 26a0433

15 files changed

+20
-259
lines changed

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/BackupPolicy/GetAzureStorSimpleDeviceBackupPolicy.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
using System.Collections.Generic;
2121
using Microsoft.WindowsAzure.Commands.Utilities.CloudService;
2222
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
23-
using Microsoft.WindowsAzure.Commands.StorSimple.Exceptions;
2423

2524
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
2625
{

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/GetAzureStorSimpleResourceContext.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.WindowsAzure.Commands.StorSimple.Exceptions;
1615
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
1716
using System;
1817
using System.Management.Automation;
@@ -25,20 +24,11 @@ namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
2524
[Cmdlet(VerbsCommon.Get, "AzureStorSimpleResourceContext"),OutputType(typeof(StorSimpleResourceContext))]
2625
public class GetAzureStorSimpleResourceContext : StorSimpleCmdletBase
2726
{
28-
//suppress resource check for this commandlet
29-
public GetAzureStorSimpleResourceContext() : base(false) { }
30-
3127
public override void ExecuteCmdlet()
3228
{
3329
try
3430
{
3531
var currentContext = StorSimpleClient.GetResourceContext();
36-
if(currentContext == null)
37-
{
38-
ResourceContextNotFoundException notFoundEx = new ResourceContextNotFoundException();
39-
throw notFoundEx;
40-
}
41-
4232
this.WriteObject(currentContext);
4333
this.WriteVerbose(string.Format(Resources.ResourceContextFound,currentContext.ResourceName, currentContext.ResourceId));
4434
}

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/SelectAzureStorSimpleResource.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
using Microsoft.WindowsAzure.Commands.StorSimple.Encryption;
1818
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
1919
using System.Management.Automation;
20-
using Microsoft.WindowsAzure.Commands.StorSimple.Exceptions;
2120

2221
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
2322
{
@@ -50,15 +49,15 @@ public override void ExecuteCmdlet()
5049
if (resCred == null)
5150
{
5251
this.WriteVerbose(Resources.NotFoundMessageResource);
53-
throw new StorSimpleResourceNotFoundException();
52+
throw GetGenericException(Resources.NotFoundMessageResource, null);
5453
}
5554

5655
StorSimpleClient.SetResourceContext(resCred);
5756
var deviceInfos = StorSimpleClient.GetAllDevices();
5857
if (!deviceInfos.Any())
5958
{
6059
StorSimpleClient.ResetResourceContext();
61-
throw new NoDeviceRegisteredException();
60+
throw base.GetGenericException(Resources.DeviceNotRegisteredMessage, null);
6261
}
6362

6463
//now check for the key

src/ServiceManagement/StorSimple/Commands.StorSimple/Commands.StorSimple.csproj

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,6 @@
142142
<Compile Include="Cmdlets\Volume\SetAzureStorSimpleDeviceVolume.cs" />
143143
<Compile Include="Encryption\EncryptionCmdLetHelper.cs" />
144144
<Compile Include="Encryption\StorSimpleKeyManager.cs" />
145-
<Compile Include="Exceptions\DeviceNotYetConfiguredException.cs" />
146-
<Compile Include="Exceptions\NoDeviceRegisteredException.cs" />
147-
<Compile Include="Exceptions\RegistrationKeyException.cs" />
148-
<Compile Include="Exceptions\StorSimpleSecretManagementException.cs" />
149-
<Compile Include="Exceptions\ResourceContextNotFoundException.cs" />
150-
<Compile Include="Exceptions\ResourceNotFoundException.cs" />
151145
<Compile Include="Library\CryptoHelper.cs" />
152146
<Compile Include="Library\IKeyManager.cs" />
153147
<Compile Include="Library\LocalKeyStoreManager.cs" />

src/ServiceManagement/StorSimple/Commands.StorSimple/Encryption/EncryptionCmdLetHelper.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
using System;
1616
using Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets.Library;
17-
using Microsoft.WindowsAzure.Commands.StorSimple.Exceptions;
1817
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
1918

2019
namespace Microsoft.WindowsAzure.Commands.StorSimple.Encryption
@@ -30,7 +29,7 @@ public static void PersistCIK(StorSimpleCmdletBase cmdlet, string resourceId, st
3029

3130
if (string.IsNullOrEmpty(cik))
3231
{
33-
throw new StorSimpleSecretManagementException(Resources.CIKInvalid, KeyStoreOperationStatus.PERSIST_EMPTY_KEY);
32+
throw new Exception(Resources.CIKInvalid);
3433
}
3534

3635
StorSimpleKeyManager mgr = cmdlet.StorSimpleClient.GetResourceContext().StorSimpleKeyManager;
@@ -45,8 +44,8 @@ public static void PersistCIK(StorSimpleCmdletBase cmdlet, string resourceId, st
4544

4645
// other error codes are NOT expected - those validations have been done already
4746
if (status != KeyStoreOperationStatus.PERSIST_SUCCESS)
48-
{
49-
throw new StorSimpleSecretManagementException(Resources.PersistSecretFailed, status);
47+
{
48+
throw new Exception(Resources.PersistSecretFailed);
5049
}
5150
}
5251

@@ -61,25 +60,25 @@ public static string RetrieveCIK(StorSimpleCmdletBase cmdlet, string resourceId)
6160
status == KeyStoreOperationStatus.RETRIEVE_FILESTREAM_INVALID)
6261
{
6362
// CIK was persisted, but has been corrupted
64-
throw new StorSimpleSecretManagementException(Resources.PersistedCIKCorrupted, status);
63+
throw new Exception(Resources.PersistedCIKCorrupted);
6564
}
6665

6766
if (status == KeyStoreOperationStatus.RETRIEVE_FILE_DOES_NOT_EXIST)
6867
{
6968
// CIK was never persisted
70-
throw new StorSimpleSecretManagementException(Resources.CIKNotPersisted, status);
69+
throw new Exception(Resources.CIKNotPersisted);
7170
}
7271

7372
// other error codes are NOT expected - those validations have been done already
7473
if (status != KeyStoreOperationStatus.RETRIEVE_SUCCESS)
7574
{
76-
throw new StorSimpleSecretManagementException(Resources.CIKFetchFailed, status);
75+
throw new Exception(Resources.CIKFetchFailed);
7776
}
7877

7978
if (string.IsNullOrEmpty(cik))
8079
{
8180
// CIK retrieved successfully, but is NULL :(
82-
throw new StorSimpleSecretManagementException(Resources.PersistedCIKIsNull, KeyStoreOperationStatus.RETRIEVE_EMPTY_KEY);
81+
throw new Exception(Resources.PersistedCIKIsNull);
8382
}
8483

8584
return cik;
@@ -94,7 +93,7 @@ public static void ValidatePersistedCIK(StorSimpleCmdletBase cmdlet, string reso
9493

9594
if (string.IsNullOrEmpty(rakPub))
9695
{
97-
throw new StorSimpleSecretManagementException(Resources.PersistedCIKValidationFailed, KeyStoreOperationStatus.VALIDATE_FAILED);
96+
throw new Exception(Resources.PersistedCIKValidationFailed);
9897
}
9998
}
10099
}

src/ServiceManagement/StorSimple/Commands.StorSimple/Exceptions/DeviceNotYetConfiguredException.cs

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/ServiceManagement/StorSimple/Commands.StorSimple/Exceptions/NoDeviceRegisteredException.cs

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/ServiceManagement/StorSimple/Commands.StorSimple/Exceptions/RegistrationKeyException.cs

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/ServiceManagement/StorSimple/Commands.StorSimple/Exceptions/ResourceContextNotFoundException.cs

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/ServiceManagement/StorSimple/Commands.StorSimple/Exceptions/ResourceNotFoundException.cs

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/ServiceManagement/StorSimple/Commands.StorSimple/Exceptions/StorSimpleSecretManagementException.cs

Lines changed: 0 additions & 30 deletions
This file was deleted.

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

Lines changed: 1 addition & 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@
397397
<value>Could not retrieve secret. Please use Select-AzureStorSimpleResource and provide the Registration key once again.</value>
398398
</data>
399399
<data name="CIKInvalid" xml:space="preserve">
400-
<value>Invalid arguments - CIK is NULL</value>
400+
<value>Invalid value for Registration Key. CIK could not be retrieved from Registration Key. Please provide the value as such from the portal!</value>
401401
</data>
402402
<data name="CIKNotPersisted" xml:space="preserve">
403403
<value>Could not find the persisted secret. Please use Select-AzureStorSimpleResource and provide the Registration key once again.</value>

src/ServiceManagement/StorSimple/Commands.StorSimple/ServiceClients/StorSimpleContextClient.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
using System.Linq;
1717
using System.Collections.Generic;
1818
using Microsoft.WindowsAzure.Commands.StorSimple.Encryption;
19-
using Microsoft.WindowsAzure.Commands.StorSimple.Exceptions;
2019
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
2120
using Microsoft.WindowsAzure.Management.Scheduler;
2221

@@ -133,7 +132,7 @@ public string ParseCIKFromRegistrationKey(string registrationKey)
133132
}
134133
catch (Exception ex)
135134
{
136-
throw new RegistrationKeyException(Resources.IncorrectFormatInRegistrationKey, ex);
135+
throw new Exception(Resources.IncorrectFormatInRegistrationKey, ex);
137136
}
138137
}
139138
}

0 commit comments

Comments
 (0)