diff --git a/src/Polly/Polly.csproj b/src/Polly/Polly.csproj
index dbd07761a27..177c9f8b3a0 100644
--- a/src/Polly/Polly.csproj
+++ b/src/Polly/Polly.csproj
@@ -7,7 +7,7 @@
Library
70
true
- $(NoWarn);CA1010;CA1031;CA1032;CA1051;CA1062;CA1063;CA1064;CA1710;CA1716;CA1724;CA1805;CA1815;CA1816;CA2211
+ $(NoWarn);CA1010;CA1031;CA1051;CA1062;CA1063;CA1064;CA1710;CA1716;CA1724;CA1805;CA1815;CA1816;CA2211
$(NoWarn);S2223;S3215;S3246;S3971;S4039;S4457
$(NoWarn);RS0037;
diff --git a/src/Polly/RateLimit/RateLimitRejectedException.cs b/src/Polly/RateLimit/RateLimitRejectedException.cs
index 3a7c9a2f5e1..e643d3af028 100644
--- a/src/Polly/RateLimit/RateLimitRejectedException.cs
+++ b/src/Polly/RateLimit/RateLimitRejectedException.cs
@@ -21,6 +21,33 @@ public class RateLimitRejectedException : ExecutionRejectedException
///
public TimeSpan RetryAfter { get; private set; }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public RateLimitRejectedException()
+ : base("The operation could not be executed because it was rejected by the rate limit.")
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The message that describes the error.
+ public RateLimitRejectedException(string message)
+ : base(message)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The message that describes the error.
+ /// The inner exception.
+ public RateLimitRejectedException(string message, Exception inner)
+ : base(message, inner)
+ {
+ }
+
///
/// Initializes a new instance of the class.
///
diff --git a/src/Polly/Utilities/TimedLock.cs b/src/Polly/Utilities/TimedLock.cs
index 901135c8af7..c215ef016f2 100644
--- a/src/Polly/Utilities/TimedLock.cs
+++ b/src/Polly/Utilities/TimedLock.cs
@@ -85,8 +85,30 @@ private class Sentinel
internal class LockTimeoutException : Exception
{
+ ///
+ /// Initializes a new instance of the class.
+ ///
public LockTimeoutException()
: base("Timeout waiting for lock")
{
}
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The message that describes the error.
+ public LockTimeoutException(string message)
+ : base(message)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The message that describes the error.
+ /// The inner exception.
+ public LockTimeoutException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
}
diff --git a/test/Polly.Specs/RateLimit/RateLimitRejectedExceptionTests.cs b/test/Polly.Specs/RateLimit/RateLimitRejectedExceptionTests.cs
new file mode 100644
index 00000000000..febc177c38f
--- /dev/null
+++ b/test/Polly.Specs/RateLimit/RateLimitRejectedExceptionTests.cs
@@ -0,0 +1,35 @@
+namespace Polly.Specs.RateLimit;
+
+public class RateLimitRejectedExceptionTests
+{
+ [Fact]
+ public void Ctor_Ok()
+ {
+ const string Dummy = "dummy";
+ var exception = new InvalidOperationException();
+ var retryAfter = TimeSpan.FromSeconds(4);
+
+ new RateLimitRejectedException().Message.Should().Be("The operation could not be executed because it was rejected by the rate limit.");
+ new RateLimitRejectedException(Dummy).Message.Should().Be(Dummy);
+
+ var rate = new RateLimitRejectedException(Dummy, exception);
+ rate.Message.Should().Be(Dummy);
+ rate.InnerException.Should().Be(exception);
+
+ new RateLimitRejectedException(retryAfter).RetryAfter.Should().Be(retryAfter);
+ new RateLimitRejectedException(retryAfter).Message.Should().Be($"The operation has been rate-limited and should be retried after {retryAfter}");
+
+ rate = new RateLimitRejectedException(retryAfter, exception);
+ rate.RetryAfter.Should().Be(retryAfter);
+ rate.InnerException.Should().Be(exception);
+
+ rate = new RateLimitRejectedException(retryAfter, Dummy);
+ rate.RetryAfter.Should().Be(retryAfter);
+ rate.Message.Should().Be(Dummy);
+
+ rate = new RateLimitRejectedException(retryAfter, Dummy, exception);
+ rate.RetryAfter.Should().Be(retryAfter);
+ rate.Message.Should().Be(Dummy);
+ rate.InnerException.Should().Be(exception);
+ }
+}
diff --git a/test/Polly.Specs/Utilities/LockTimeoutExceptionTests.cs b/test/Polly.Specs/Utilities/LockTimeoutExceptionTests.cs
new file mode 100644
index 00000000000..3f140045d49
--- /dev/null
+++ b/test/Polly.Specs/Utilities/LockTimeoutExceptionTests.cs
@@ -0,0 +1,18 @@
+namespace Polly.Specs.Utilities;
+
+public class LockTimeoutExceptionTests
+{
+ [Fact]
+ public void Ctor_Ok()
+ {
+ const string Dummy = "dummy";
+ var exception = new InvalidOperationException();
+
+ new LockTimeoutException().Message.Should().Be("Timeout waiting for lock");
+ new LockTimeoutException(Dummy).Message.Should().Be(Dummy);
+
+ var rate = new LockTimeoutException(Dummy, exception);
+ rate.Message.Should().Be(Dummy);
+ rate.InnerException.Should().Be(exception);
+ }
+}