Skip to content

Commit

Permalink
improving Exception messages for BatchSize and FlushTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
brettsam committed Jul 3, 2017
1 parent 9ac4e2a commit 25dcfef
Showing 1 changed file with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,10 @@ public int BatchSize

set
{
if (value <= 0)
if (value <= 0 || value > MaxBatchSize)
{
throw new ArgumentOutOfRangeException(nameof(value));
}

if (value > MaxBatchSize)
{
throw new ArgumentOutOfRangeException(nameof(value));
string message = $"'{nameof(BatchSize)}' value must be greater than 0 and less than or equal to {MaxBatchSize}.";
throw new ArgumentOutOfRangeException(null, value, message);
}

_batchSize = value;
Expand All @@ -67,14 +63,10 @@ public TimeSpan FlushTimeout

set
{
if (value <= TimeSpan.Zero)
{
throw new ArgumentOutOfRangeException(nameof(value));
}

if (value > MaxFlushTimeout)
if (value <= TimeSpan.Zero || value > MaxFlushTimeout)
{
throw new ArgumentOutOfRangeException(nameof(value));
string message = $"'{nameof(FlushTimeout)}' value must be greater than '{TimeSpan.Zero.ToString()}' and less than or equal to '{MaxFlushTimeout.ToString()}'.";
throw new ArgumentOutOfRangeException(null, value, message);
}

_flushTimeout = value;
Expand Down

0 comments on commit 25dcfef

Please sign in to comment.