Skip to content

Commit e016ebd

Browse files
committed
Address CRs
1 parent 6d9910d commit e016ebd

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

src/Common/Commands.Common/ComputeCloudException.cs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,30 @@ public ComputeCloudException(CloudException ex)
2828
{
2929
}
3030

31-
protected static string GetErrorMessageWithRequestIdInfo(CloudException ex)
31+
protected static string GetErrorMessageWithRequestIdInfo(CloudException cloudException)
3232
{
33-
var sb = new StringBuilder(ex.Message);
33+
if (cloudException == null)
34+
{
35+
throw new ArgumentNullException("cloudException");
36+
}
37+
38+
var sb = new StringBuilder(cloudException.Message);
3439

35-
if (ex.Response != null && ex.Response.Headers.ContainsKey(RequestIdHeaderInResponse))
40+
if (cloudException.Response != null)
3641
{
37-
if (sb.Length > 0)
42+
var headers = cloudException.Response.Headers;
43+
if (headers != null && headers.ContainsKey(RequestIdHeaderInResponse))
3844
{
39-
// If the original exception message is not empty, append a new line here.
40-
sb.Append(Environment.NewLine);
41-
}
45+
if (sb.Length > 0)
46+
{
47+
// If the original exception message is not empty, append a new line here.
48+
sb.Append(Environment.NewLine);
49+
}
4250

43-
sb.AppendFormat(
44-
Properties.Resources.ComputeCloudExceptionOperationIdMessage,
45-
ex.Response.Headers[RequestIdHeaderInResponse].FirstOrDefault());
51+
sb.AppendFormat(
52+
Properties.Resources.ComputeCloudExceptionOperationIdMessage,
53+
headers[RequestIdHeaderInResponse].FirstOrDefault());
54+
}
4655
}
4756

4857
return sb.ToString();

0 commit comments

Comments
 (0)