Skip to content

Commit be0d1bd

Browse files
committed
converting all write verbose messages to throw exceptions, wherever it is meant to be errors
1 parent 23555ec commit be0d1bd

File tree

35 files changed

+71
-159
lines changed

35 files changed

+71
-159
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: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
1-
#region Using directives
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
216
using System;
17+
using System.Collections.Generic;
318
using System.Management.Automation;
4-
#endregion
19+
using Microsoft.WindowsAzure.Management.StorSimple.Models;
20+
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
521

622

723
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
824
{
9-
using System.Collections.Generic;
10-
11-
using Microsoft.WindowsAzure.Commands.StorSimple;
12-
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
13-
using Microsoft.WindowsAzure.Management.StorSimple.Models;
14-
1525
/// <summary>
1626
/// Given a backupId, snapshot and a targetDeviceName , this commandlet will
1727
/// clone it on the given target device.
@@ -108,24 +118,22 @@ private bool ProcessParameters()
108118

109119
if (this.sourceDeviceId == null)
110120
{
111-
WriteVerbose(Resources.NoDeviceFoundWithGivenNameInResourceMessage);
112-
return false;
121+
throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, SourceDeviceName));
113122
}
114123

115124
this.targetDeviceId = StorSimpleClient.GetDeviceId(TargetDeviceName);
116125

117126
if (this.targetDeviceId == null)
118127
{
119-
WriteVerbose(Resources.NoDeviceFoundWithGivenNameInResourceMessage);
120-
return false;
128+
throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, TargetDeviceName));
121129
}
122130
break;
123131
}
124132

125133
return true;
126134
}
127135

128-
}//End Class
136+
}
129137

130-
}//End namespace
138+
}
131139

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

0 commit comments

Comments
 (0)