Skip to content

Commit

Permalink
Guard.Range now uses invariant culture for error message (#3778)
Browse files Browse the repository at this point in the history
Co-authored-by: Utkarsh Umesan Pillai <[email protected]>
  • Loading branch information
Driedas and utpilla authored Oct 21, 2022
1 parent d4cbc0c commit 3c245ef
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/OpenTelemetry.Api/Internal/Guard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

using System;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Threading;

Expand Down Expand Up @@ -198,7 +199,13 @@ private static void Range<T>(T value, string? paramName, T min, T max, string? m
{
var minMessage = minName != null ? $": {minName}" : string.Empty;
var maxMessage = maxName != null ? $": {maxName}" : string.Empty;
var exMessage = message ?? $"Must be in the range: [{min}{minMessage}, {max}{maxMessage}]";
var exMessage = message ?? string.Format(
CultureInfo.InvariantCulture,
"Must be in the range: [{0}{1}, {2}{3}]",
min,
minMessage,
max,
maxMessage);
throw new ArgumentOutOfRangeException(paramName, value, exMessage);
}
}
Expand Down

0 comments on commit 3c245ef

Please sign in to comment.