Skip to content

Commit 73325f4

Browse files
committed
Change the exception message.
1 parent 6b69c3f commit 73325f4

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Handlers/RetryHandler.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
5757
{
5858
HttpResponseMessage response = null;
5959

60-
for (int attempt = 0; attempt < RetryHandler.MaxAttempts; ++attempt)
60+
for (int attempt = 1; attempt <= RetryHandler.MaxAttempts; ++attempt)
6161
{
6262
try
6363
{
6464
response = await base.SendAsync(request: request, cancellationToken: cancellationToken)
6565
.ConfigureAwait(continueOnCapturedContext: false);
6666

67-
if (attempt == RetryHandler.MaxAttempts - 1 ||
67+
if (attempt == RetryHandler.MaxAttempts ||
6868
(!response.StatusCode.IsServerFailureRequest() &&
6969
response.StatusCode != HttpStatusCode.RequestTimeout &&
7070
response.StatusCode != HttpStatusCodeExt.TooManyRequests))
@@ -74,7 +74,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
7474
}
7575
catch (Exception ex)
7676
{
77-
if (ex.IsFatal() || attempt == RetryHandler.MaxAttempts - 1)
77+
if (ex.IsFatal() || attempt == RetryHandler.MaxAttempts)
7878
{
7979
throw;
8080
}
@@ -89,6 +89,7 @@ await Task.Delay(delay: RetryHandler.GetDelay(attempt), cancellationToken: cance
8989
.ConfigureAwait(continueOnCapturedContext: false);
9090
}
9191

92+
/// should never reach here.
9293
return null;
9394
}
9495

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Properties/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,4 +396,7 @@
396396
<data name="UpdatedResourceGroup" xml:space="preserve">
397397
<value>Updated resource group '{0}' in location '{1}'</value>
398398
</data>
399+
<data name="OperationFailedWithTimeOut" xml:space="preserve">
400+
<value>Operation failed because a request time out.</value>
401+
</data>
399402
</root>

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/RestClients/ResourceManagerRestClientBase.cs

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

1515
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.RestClients
1616
{
17+
using System;
18+
using System.Net.Http;
19+
using System.Text;
20+
using System.Threading;
21+
using System.Threading.Tasks;
1722
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
1823
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.ErrorResponses;
1924
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Extensions;
2025
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Utilities;
2126
using Newtonsoft.Json;
2227
using Newtonsoft.Json.Linq;
23-
using System;
24-
using System.Net.Http;
25-
using System.Text;
26-
using System.Threading;
27-
using System.Threading.Tasks;
28+
using ProjectResources = Microsoft.Azure.Commands.ResourceManager.Cmdlets.Properties.Resources;
2829

2930
/// <summary>
3031
/// A base class for Azure clients.
@@ -247,7 +248,7 @@ protected async Task<HttpResponseMessage> SendRequestAsync(HttpRequestMessage re
247248
{
248249
if (exception is OperationCanceledException && !cancellationToken.IsCancellationRequested)
249250
{
250-
throw new TimeoutException("A request times out.");
251+
throw new Exception(ProjectResources.OperationFailedWithTimeOut);
251252
}
252253

253254
throw;

0 commit comments

Comments
 (0)