Skip to content

Commit abe2b4c

Browse files
authored
Update service error codes (#3315)
* Update service error codes * Fix transientness of associated exceptions
1 parent 06d0936 commit abe2b4c

File tree

12 files changed

+58
-48
lines changed

12 files changed

+58
-48
lines changed

e2e/test/iothub/DeviceClientE2eTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ public async Task DeviceClient_CloseAsync_CanBeCalledTwice()
3636
finally
3737
{
3838
await testDevice.RemoveDeviceAsync().ConfigureAwait(false);
39-
testDevice.Dispose();
4039
}
41-
4240
}
4341
}
4442
}

iothub/device/src/Common/Exceptions/IotHubException.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,16 @@ protected IotHubException(SerializationInfo info, StreamingContext context)
129129
}
130130
}
131131

132-
internal IotHubException(bool isTransient) : base()
132+
internal IotHubException(bool isTransient)
133+
: base()
133134
{
134135
IsTransient = isTransient;
135136
}
136137

137138
/// <summary>
138139
/// Indicates if the error is transient and should be retried.
139140
/// </summary>
140-
public bool IsTransient { get; private set; }
141+
public bool IsTransient { get; protected set; }
141142

142143
/// <summary>
143144
/// The service returned tracking Id associated with this particular error.

iothub/device/src/Common/Exceptions/IotHubThrottledException.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public sealed class IotHubThrottledException : IotHubException
2020
/// <summary>
2121
/// Initializes a new instance of the class.
2222
/// </summary>
23-
public IotHubThrottledException() : base(isTransient: true)
23+
public IotHubThrottledException()
24+
: base(isTransient: true)
2425
{
2526
}
2627

@@ -65,6 +66,7 @@ public IotHubThrottledException(string message, Exception innerException)
6566
private IotHubThrottledException(SerializationInfo info, StreamingContext context)
6667
: base(info, context)
6768
{
69+
IsTransient = true;
6870
}
6971
}
7072
}

iothub/device/src/Common/Exceptions/QuotaExceededException.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public sealed class QuotaExceededException : IotHubException
1919
/// <summary>
2020
/// Initializes a new instance of the class.
2121
/// </summary>
22-
public QuotaExceededException() : base(isTransient: true)
22+
public QuotaExceededException()
23+
: base(isTransient: true)
2324
{
2425
}
2526

@@ -30,7 +31,7 @@ public QuotaExceededException() : base(isTransient: true)
3031
/// understood by humans. The caller of this constructor is required to ensure that this string has
3132
/// been localized for the current system culture.</param>
3233
public QuotaExceededException(string message)
33-
: this(message, null)
34+
: base(message, true)
3435
{
3536
}
3637

iothub/device/src/Common/Exceptions/ServerBusyException.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public sealed class ServerBusyException : IotHubException
2020
/// <summary>
2121
/// Initializes a new instance of the class.
2222
/// </summary>
23-
public ServerBusyException() : base(isTransient: true)
23+
public ServerBusyException()
24+
: base(isTransient: true)
2425
{
2526
}
2627

@@ -29,7 +30,7 @@ public ServerBusyException() : base(isTransient: true)
2930
/// </summary>
3031
/// <param name="message">The error message.</param>
3132
public ServerBusyException(string message)
32-
: this(message, null)
33+
: base(message, true)
3334
{
3435
}
3536

@@ -43,6 +44,7 @@ public ServerBusyException(string message, Exception innerException)
4344
private ServerBusyException(SerializationInfo info, StreamingContext context)
4445
: base(info, context)
4546
{
47+
IsTransient = true;
4648
}
4749
}
4850
}

iothub/service/src/Common/Exceptions/ErrorCode.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,12 @@ public enum ErrorCode
292292

293293
// Throttling Exception
294294

295+
/// <summary>
296+
/// IoT hub throttling limits have been exceeded for the requested operation.
297+
/// For more information, <see href="https://aka.ms/iothubthrottling">IoT hub quotas and throttling</see>.
298+
/// </summary>
299+
GenericTooManyRequests = 429000,
300+
295301
/// <summary>
296302
/// IoT hub throttling limits have been exceeded for the requested operation.
297303
/// For more information, <see href="https://aka.ms/iothubthrottling">IoT hub quotas and throttling</see>.
@@ -306,6 +312,24 @@ public enum ErrorCode
306312
/// </summary>
307313
ThrottleBacklogLimitExceeded = 429002,
308314

315+
/// <summary>
316+
/// IoT hub throttling limits have been exceeded for the requested operation.
317+
/// For more information, <see href="https://aka.ms/iothubthrottling">IoT hub quotas and throttling</see>.
318+
/// </summary>
319+
ThrottlingBacklogTimeout = 429003,
320+
321+
/// <summary>
322+
/// IoT hub throttling limits have been exceeded for the requested operation.
323+
/// For more information, <see href="https://aka.ms/iothubthrottling">IoT hub quotas and throttling</see>.
324+
/// </summary>
325+
ThrottlingMaxActiveJobCountExceeded = 429004,
326+
327+
/// <summary>
328+
/// IoT hub throttling limits have been exceeded for the requested operation.
329+
/// For more information, <see href="https://aka.ms/iothubthrottling">IoT hub quotas and throttling</see>.
330+
/// </summary>
331+
DeviceThrottlingLimitExceeded = 429005,
332+
309333
/// <summary>
310334
/// IoT hub ran into a server side issue when attempting to throttle.
311335
/// <para>

iothub/service/src/Common/Exceptions/IotHubException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ internal IotHubException()
157157
/// <summary>
158158
/// Indicates if the error is transient and should be retried.
159159
/// </summary>
160-
public bool IsTransient { get; private set; }
160+
public bool IsTransient { get; protected set; }
161161

162162
/// <summary>
163163
/// The service returned tracking Id associated with this particular error.

iothub/service/src/Common/Exceptions/IotHubThrottledException.cs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,29 @@ public sealed class IotHubThrottledException : IotHubException
1818
{
1919
/// <summary>
2020
/// Creates an instance of this class with the value of the
21-
/// maximum allowed count of active requests and marks it as non-transient.
21+
/// maximum allowed count of active requests and marks it as transient.
2222
/// </summary>
2323
/// <param name="maximumBatchCount">The maximum allowed count of active requests.</param>
2424
public IotHubThrottledException(int maximumBatchCount)
25-
: this($"Device Container has exceeded maximum number of allowed active requests: {maximumBatchCount}.")
25+
: base($"Device Container has exceeded maximum number of allowed active requests: {maximumBatchCount}.", true)
2626
{
2727
}
2828

2929
/// <summary>
3030
/// Creates an instance of this class with a specified error message and
31-
/// a reference to the inner exception that caused this exception, and marks it as non-transient.
31+
/// a reference to the inner exception that caused this exception, and marks it as transient.
3232
/// </summary>
3333
/// <param name="message">The message that describes the error.</param>
3434
/// <param name="innerException">The exception that is the cause of the current exception.</param>
3535
public IotHubThrottledException(string message, Exception innerException)
36-
: base(message, innerException)
37-
{
38-
}
39-
40-
internal IotHubThrottledException()
41-
: base()
42-
{
43-
}
44-
45-
internal IotHubThrottledException(string message)
46-
: base(message)
36+
: base(message, innerException, true)
4737
{
4838
}
4939

5040
private IotHubThrottledException(SerializationInfo info, StreamingContext context)
5141
: base(info, context)
5242
{
43+
IsTransient = true;
5344
}
5445
}
5546
}

iothub/service/src/Common/Exceptions/JobQuotaExceededException.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,33 @@ public sealed class JobQuotaExceededException : IotHubException
1515
private const string DefaultErrorMessage = "Job quota has been exceeded.";
1616

1717
/// <summary>
18-
/// Creates an instance of this class with the default error message and marks it as non-transient.
18+
/// Creates an instance of this class with the default error message and marks it as transient.
1919
/// </summary>
2020
public JobQuotaExceededException()
2121
: this(DefaultErrorMessage)
2222
{
2323
}
2424

2525
/// <summary>
26-
/// Creates an instance of this class with a specified error message and marks it as non-transient.
26+
/// Creates an instance of this class with a specified error message and marks it as transient.
2727
/// </summary>
2828
/// <param name="message">The message that describes the error.</param>
2929
public JobQuotaExceededException(string message)
30-
: base(message)
30+
: base(message, true)
3131
{
3232
}
3333

3434
internal JobQuotaExceededException(string message, Exception innerException)
3535
: base(message, innerException)
3636
{
37+
38+
IsTransient = true;
3739
}
3840

3941
private JobQuotaExceededException(SerializationInfo info, StreamingContext context)
4042
: base(info, context)
4143
{
44+
IsTransient = true;
4245
}
4346
}
4447
}

iothub/service/src/Common/Exceptions/QuotaExceededException.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public sealed class QuotaExceededException : IotHubException
2222
/// </summary>
2323
/// <param name="message">The message that describes the error.</param>
2424
public QuotaExceededException(string message)
25-
: this(message, null)
25+
: base(message, true)
2626
{
2727
}
2828

@@ -48,14 +48,10 @@ public QuotaExceededException(string message, Exception innerException)
4848
{
4949
}
5050

51-
internal QuotaExceededException()
52-
: base()
53-
{
54-
}
55-
5651
private QuotaExceededException(SerializationInfo info, StreamingContext context)
5752
: base(info, context)
5853
{
54+
IsTransient = true;
5955
}
6056
}
6157
}

0 commit comments

Comments
 (0)