mgth/LittleBigMouse · error · ArgumentOutOfRangeException
Enter a test level between 0 and 10.
Error message
Enter a test level between 0 and 10.
What it means
ExperimentalLevelPayload serializes an integer experimental/test level value into a payload string for the Hisense VIDAA protocol. Only values 0 through 10 are accepted; anything outside that range throws ArgumentOutOfRangeException, since the device firmware only understands test levels in that band.
Solutions
- Clamp the value with Math.Clamp(value, 0, 10) before calling ExperimentalLevelPayload.
- Validate the range in the UI layer (slider min=0 max=10) so out-of-range values cannot be produced.
- Parse user input as int and check 0 <= value <= 10 before invoking the API.
- Catch ArgumentOutOfRangeException to show the 'Enter a test level between 0 and 10' message.
Example fix
// before var payload = ExperimentalLevelPayload(level); // level = 42 // after var payload = ExperimentalLevelPayload(Math.Clamp(level, 0, 10));
Defensive patterns
Strategy: validation
Validate before calling
public static bool IsValidExperimentalLevel(int value) => value is >= 0 and <= 10; // use: if (!IsValidExperimentalLevel(level)) level = Math.Clamp(level, 0, 10);
Try / catch
try { var payload = HisenseVidaaProtocol.ExperimentalLevelPayload(level); }
catch (ArgumentOutOfRangeException) { level = Math.Clamp(level, 0, 10); } Prevention
- Clamp with Math.Clamp(value, 0, 10) at every call site.
- Bind the UI control to min=0, max=10.
- Convert percentages (0-100) to levels explicitly before sending.
When it happens
Trigger: Calling ExperimentalLevelPayload with an int less than 0 or greater than 10, e.g. ExperimentalLevelPayload(-1) or ExperimentalLevelPayload(11), typically from a slider/numeric input not clamped before submission.
Common situations: A UI slider or text box allowing values beyond 0-10; copying a percentage (0-100) instead of a 0-10 level; off-by-one bounds like 10 vs 11; parsing user input without range validation.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Enter a platform action name containing only letters…
- Enter the four-digit PIN displayed by the Hisense device.
- Enter the projector Wi-Fi MAC address first.
- The C1 requires the VIDAA client certificate. Extract the…
- The C1 requires the VIDAA client certificate. Extract the…
AI-assisted analysis of mgth/LittleBigMouse@7a42f01d47 (2026-09-16).
Data as JSON: /api/errors/79d4c130320e6b73.
Report an issue: GitHub.
Appendix: source
Thrown at LittleBigMouse.Plugins/LittleBigMouse.Plugin.Vcp.Avalonia/HisenseVidaa/HisenseVidaaProtocol.cs:214
throw new ArgumentOutOfRangeException(nameof(volume), "Enter a volume between 0 and 100.");
return volume.ToString(CultureInfo.InvariantCulture);
}
public static string PlatformActionName(string action)
{
var normalized = action.Trim();
if (normalized.Length is 0 or > 64
|| normalized.Any(c => !char.IsAsciiLetterOrDigit(c) && c is not '_' and not '-'))
throw new ArgumentException(
"Enter a platform action name containing only letters, digits, '_' or '-'.",
nameof(action));
return normalized;
}
public static string ExperimentalLevelPayload(int value)
{
if (value is < 0 or > 10)
throw new ArgumentOutOfRangeException(nameof(value), "Enter a test level between 0 and 10.");
return value.ToString(CultureInfo.InvariantCulture);
}
public static bool TryParseVolume(string topic, string payload, out int volume)
{
volume = 0;
if (!topic.EndsWith("/platform_service/actions/volumechange", StringComparison.OrdinalIgnoreCase))
return false;
try
{
using var json = JsonDocument.Parse(payload);
return json.RootElement.TryGetProperty("volume_value", out var value)
&& value.TryGetInt32(out volume)
&& volume is >= 0 and <= 100;
}
catch (JsonException)
{
return false;View on GitHub (pinned to 7a42f01d47)