Skip to content

Commit 9d5597a

Browse files
committed
Merge pull request #48 from AzCiS/parvezah
converting all write verbose messages to throw exceptions, wherever it i...
2 parents f1dc520 + 151dadf commit 9d5597a

File tree

37 files changed

+53
-163
lines changed

37 files changed

+53
-163
lines changed

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

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

15-
using System.Linq;
1615
using System.Management.Automation;
1716
using Microsoft.WindowsAzure.Management.StorSimple.Models;
18-
using Microsoft.WindowsAzure;
1917
using System;
2018
using System.Collections.Generic;
21-
using Microsoft.WindowsAzure.Commands.Utilities.CloudService;
2219
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
2320

2421
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
@@ -78,10 +75,9 @@ private bool ProcessParameters()
7875

7976
if (deviceId == null)
8077
{
81-
WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
82-
WriteObject(null);
83-
return false;
78+
throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
8479
}
80+
8581
return true;
8682
}
8783
}

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

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

15-
using System.Linq;
1615
using System.Management.Automation;
1716
using Microsoft.WindowsAzure.Management.StorSimple.Models;
18-
using Microsoft.WindowsAzure;
1917
using System;
2018
using System.Collections.Generic;
21-
using Microsoft.WindowsAzure.Commands.Utilities.CloudService;
2219
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
2320

2421
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
@@ -84,11 +81,10 @@ public override void ExecuteCmdlet()
8481
private bool ProcessParameters()
8582
{
8683
deviceId = StorSimpleClient.GetDeviceId(DeviceName);
84+
8785
if (deviceId == null)
8886
{
89-
WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
90-
WriteObject(null);
91-
return false;
87+
throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
9288
}
9389

9490
ProcessAddSchedules();

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414

1515
using System.Management.Automation;
1616
using Microsoft.WindowsAzure.Management.StorSimple.Models;
17-
using Microsoft.WindowsAzure;
1817
using System;
19-
using System.Collections.Generic;
20-
using Microsoft.WindowsAzure.Commands.Utilities.CloudService;
21-
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
2218

2319
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
2420
{

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414

1515
using System.Management.Automation;
1616
using Microsoft.WindowsAzure.Management.StorSimple.Models;
17-
using Microsoft.WindowsAzure;
1817
using System;
19-
using System.Collections.Generic;
20-
using Microsoft.WindowsAzure.Commands.Utilities.CloudService;
21-
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
2218

2319
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
2420
{

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,9 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System.Linq;
1615
using System.Management.Automation;
1716
using Microsoft.WindowsAzure.Management.StorSimple.Models;
18-
using Microsoft.WindowsAzure;
1917
using System;
20-
using System.Collections.Generic;
21-
using Microsoft.WindowsAzure.Commands.Utilities.CloudService;
2218
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
2319

2420
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
@@ -85,9 +81,7 @@ private bool ProcessParameters()
8581

8682
if (deviceId == null)
8783
{
88-
WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
89-
WriteObject(null);
90-
return false;
84+
throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
9185
}
9286
switch (ParameterSetName)
9387
{

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,11 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System.Diagnostics;
16-
using System.Linq;
1715
using System.Management.Automation;
1816
using Microsoft.WindowsAzure.Management.StorSimple.Models;
19-
using Microsoft.WindowsAzure;
2017
using System;
2118
using System.Collections.Generic;
22-
using Microsoft.WindowsAzure.Commands.Utilities.CloudService;
2319
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
24-
using System.Text.RegularExpressions;
2520

2621
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
2722
{
@@ -114,11 +109,10 @@ public override void ExecuteCmdlet()
114109
private bool ProcessParameters()
115110
{
116111
deviceId = StorSimpleClient.GetDeviceId(DeviceName);
112+
117113
if (deviceId == null)
118114
{
119-
WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
120-
WriteObject(null);
121-
return false;
115+
throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
122116
}
123117

124118
ProcessAddSchedules();

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/BackupSet/GetAzureStorSimpleDeviceBackup.cs

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

15-
using System.Linq;
1615
using System.Management.Automation;
1716
using Microsoft.WindowsAzure.Management.StorSimple.Models;
18-
using Microsoft.WindowsAzure;
1917
using System;
2018
using System.Collections.Generic;
21-
using Microsoft.WindowsAzure.Commands.Utilities.CloudService;
2219
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
2320

2421
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
@@ -73,13 +70,15 @@ public override void ExecuteCmdlet()
7370
{
7471
try
7572
{
76-
if (!ProcessParameters()) return;
73+
if (!ProcessParameters())
74+
return;
7775
GetBackupResponse backupList = null;
7876
backupList = StorSimpleClient.GetAllBackups(deviceId, filterType, isAllSelected, IdToPass,
7977
FromDateTime.ToString(),
8078
ToDateTime.ToString(), Skip == null ? "0" : Skip.ToString(), First == null ? null : First.ToString());
8179
WriteObject(backupList.BackupSetsList, true);
8280
WriteVerbose(string.Format(Resources.BackupsReturnedCount, backupList.BackupSetsList.Count));
81+
8382
if (backupList.NextPageUri != null
8483
&& backupList.NextPageStartIdentifier!="1")
8584
{
@@ -113,9 +112,7 @@ private bool ProcessParameters()
113112

114113
if (deviceId == null)
115114
{
116-
WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
117-
WriteObject(null);
118-
return false;
115+
throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
119116
}
120117

121118
if (string.IsNullOrEmpty(From))

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/BackupSet/RemoveAzureStorSimpleDeviceBackup.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,9 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System.Linq;
1615
using System.Management.Automation;
17-
using System.Runtime.InteropServices.WindowsRuntime;
1816
using Microsoft.WindowsAzure.Management.StorSimple.Models;
19-
using Microsoft.WindowsAzure;
2017
using System;
21-
using System.Collections.Generic;
22-
using Microsoft.WindowsAzure.Commands.Utilities.CloudService;
2318
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
2419

2520

@@ -89,9 +84,7 @@ private bool ProcessParameters()
8984

9085
if (deviceId == null)
9186
{
92-
WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
93-
WriteObject(null);
94-
return false;
87+
throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
9588
}
9689
switch (ParameterSetName)
9790
{

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/BackupSet/StartAzureStorSimpleDeviceBackupJob.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,9 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System.Linq;
1615
using System.Management.Automation;
1716
using Microsoft.WindowsAzure.Management.StorSimple.Models;
18-
using Microsoft.WindowsAzure;
1917
using System;
20-
using System.Collections.Generic;
21-
using Microsoft.WindowsAzure.Commands.Utilities.CloudService;
2218
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
2319

2420
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
@@ -77,7 +73,7 @@ private void ProcessParameters()
7773

7874
if (deviceId == null)
7975
{
80-
WriteVerbose(Resources.NotFoundMessageDevice);
76+
throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
8177
}
8278

8379
BackupType backupTypeSelected = Management.StorSimple.Models.BackupType.Invalid;

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/BackupSet/StartAzureStorSimpleDeviceBackupRestoreJob.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,9 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System.Linq;
1615
using System.Management.Automation;
1716
using Microsoft.WindowsAzure.Management.StorSimple.Models;
18-
using Microsoft.WindowsAzure;
1917
using System;
20-
using System.Collections.Generic;
21-
using Microsoft.WindowsAzure.Commands.Utilities.CloudService;
2218
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
2319

2420
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
@@ -87,7 +83,7 @@ private void ProcessParameters()
8783

8884
if (deviceId == null)
8985
{
90-
WriteVerbose(Resources.NotFoundMessageDevice);
86+
throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
9187
}
9288
}
9389
}

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/Clone/StartAzureStorSimpleBackupCloneJob.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,24 +117,22 @@ private bool ProcessParameters()
117117

118118
if (this.sourceDeviceId == null)
119119
{
120-
WriteVerbose(Resources.NoDeviceFoundWithGivenNameInResourceMessage);
121-
return false;
120+
throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, SourceDeviceName));
122121
}
123122

124123
this.targetDeviceId = StorSimpleClient.GetDeviceId(TargetDeviceName);
125124

126125
if (this.targetDeviceId == null)
127126
{
128-
WriteVerbose(Resources.NoDeviceFoundWithGivenNameInResourceMessage);
129-
return false;
127+
throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, TargetDeviceName));
130128
}
131129
break;
132130
}
133131

134132
return true;
135133
}
136134

137-
}//End Class
135+
}
138136

139-
}//End namespace
137+
}
140138

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/DataContainer/GetAzureStorSimpleDeviceVolumeContainer.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ public override void ExecuteCmdlet()
4242

4343
if (deviceid == null)
4444
{
45-
WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
46-
WriteObject(null);
47-
return;
45+
throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
4846
}
4947

5048
if (VolumeContainerName == null)

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/DataContainer/NewAzureStorSimpleDeviceVolumeContainer.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ public override void ExecuteCmdlet()
6060
string deviceid = StorSimpleClient.GetDeviceId(DeviceName);
6161
if (deviceid == null)
6262
{
63-
WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
64-
WriteObject(null);
65-
return;
63+
throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
6664
}
6765

6866
if(EncryptionEnabled == true && (string.IsNullOrEmpty(EncryptionKey) || !IsValidAsciiString(EncryptionKey)))

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/DataContainer/RemoveAzureStorSimpleDeviceVolumeContainer.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ public override void ExecuteCmdlet()
5050

5151
if (deviceid == null)
5252
{
53-
WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
54-
WriteObject(null);
55-
return;
53+
throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
5654
}
5755

5856
if (WaitForComplete.IsPresent)

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/DeviceDetails/NewAzureStorSimpleNetworkConfig.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
using System;
1616
using System.Management.Automation;
17-
using Hyak.Common;
1817
using Microsoft.WindowsAzure.Management.StorSimple.Models;
1918
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
2019
using System.Net;

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/DeviceDetails/SetAzureStorSimpleDevice.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@
1515
using System;
1616
using System.Linq;
1717
using System.Management.Automation;
18-
using Hyak.Common;
1918
using Microsoft.WindowsAzure.Management.StorSimple.Models;
2019
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
21-
using System.Net.Sockets;
2220
using System.Net;
23-
using System.Collections.Generic;
2421

2522
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
2623
{

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/DeviceDetails/SetAzureStorSimpleVirtualDevice.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,10 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System;
16-
using System.Linq;
1716
using System.Management.Automation;
18-
using Hyak.Common;
1917
using Microsoft.WindowsAzure.Management.StorSimple.Models;
2018
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
21-
using System.Net.Sockets;
22-
using System.Net;
2319
using Microsoft.WindowsAzure.Commands.StorSimple.Encryption;
24-
using Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets.Library;
2520

2621
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
2722
{

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/DeviceJobs/GetAzureStorSimpleJob.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System;
16-
using System.Linq;
1716
using System.Management.Automation;
18-
using Hyak.Common;
1917
using Microsoft.WindowsAzure.Management.StorSimple.Models;
2018
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
21-
using Microsoft.WindowsAzure.Commands.StorSimple;
22-
using System.Net.Sockets;
2319
using System.Collections.Generic;
2420
using System.Xml;
2521

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/DeviceJobs/StopAzureStorSimpleJob.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System;
16-
using System.Linq;
1716
using System.Management.Automation;
18-
using Hyak.Common;
1917
using Microsoft.WindowsAzure.Management.StorSimple.Models;
2018
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
21-
using Microsoft.WindowsAzure.Commands.StorSimple;
22-
using System.Net.Sockets;
2319

2420
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
2521
{

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/Failover/GetAzureStorSimpleFailoverVolumeContainers.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,14 @@ public override void ExecuteCmdlet()
4848
}
4949
else
5050
{
51-
WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenIdInResourceMessage, StorSimpleContext.ResourceName, DeviceId));
51+
throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenIdInResourceMessage, StorSimpleContext.ResourceName, DeviceId));
5252
}
5353
break;
5454
case StorSimpleCmdletParameterSet.IdentifyByName:
5555
deviceid = StorSimpleClient.GetDeviceId(DeviceName);
5656
if (deviceid == null)
5757
{
58-
WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage,
59-
StorSimpleContext.ResourceName, DeviceName));
58+
throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
6059
}
6160
break;
6261
default:

0 commit comments

Comments
 (0)