diff --git a/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/LeakyBucket.cs b/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/LeakyBucket.cs index 74e0858a..48332c3f 100644 --- a/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/LeakyBucket.cs +++ b/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/LeakyBucket.cs @@ -59,8 +59,17 @@ internal LeakyBucket(int maximumAvailable, int restoreRatePerSecond, Func maximumAvailable) - throw new ArgumentOutOfRangeException(); + if (maximumAvailable <= 0) + throw new ArgumentOutOfRangeException($"{nameof(maximumAvailable)} ({maximumAvailable}) must be greater than zero"); + + if (currentlyAvailable < 0) + throw new ArgumentOutOfRangeException($"{nameof(currentlyAvailable)} ({currentlyAvailable}) must be positive or zero."); + + if (restoreRatePerSecond <= 0) + throw new ArgumentOutOfRangeException($"{nameof(restoreRatePerSecond)} ({restoreRatePerSecond}) must be greater than zero"); + + if (currentlyAvailable > maximumAvailable) + throw new ArgumentOutOfRangeException($"{nameof(currentlyAvailable)} ({currentlyAvailable}) must not be greater than {nameof(maximumAvailable)} ({maximumAvailable})"); lock (_lock) {