stride3d/stride · error · ArgumentOutOfRangeException
value
Error message
value
What it means
GestureConfigFlick.AllowedErrorMargin throws ArgumentOutOfRangeException with paramName "value" when either X or Y of the Vector2 is negative. It defines the directional tolerance cone for flick recognition, so both components must be >= 0.
Solutions
- Provide a Vector2 with both components >= 0, e.g. new Vector2(5, 5)
- Take absolute values of computed components before assignment
- Validate values loaded from settings before assigning
Example fix
// before flickConfig.AllowedErrorMargin = new Vector2(dx, dy); // dx < 0 // after flickConfig.AllowedErrorMargin = new Vector2(Math.Abs(dx), Math.Abs(dy));
Defensive patterns
Strategy: validation
Validate before calling
if (margin.X < 0f || margin.Y < 0f) throw new ArgumentException("AllowedErrorMargin components must be >= 0");
flickConfig.AllowedErrorMargin = margin; Type guard
bool IsValidMargin(Vector2 v) => v.X >= 0f && v.Y >= 0f;
Try / catch
try { flickConfig.AllowedErrorMargin = margin; }
catch (ArgumentOutOfRangeException ex) when (ex.ParamName == "value")
{
flickConfig.AllowedErrorMargin = Vector2.Abs(margin);
} Prevention
- Normalize flick direction math before reusing values as margins
- Validate Vector2 config fields component-wise
- Keep margin values separate from signed screen-coordinate math
When it happens
Trigger: Assigning a Vector2 with a negative component to AllowedErrorMargin on an unfrozen GestureConfigFlick, commonly from signed delta or angle math.
Common situations: Reusing drag-gesture margin values computed with signs; subtracting screen coordinates without normalizing; negative sentinel values in config.
Related errors
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/718b08222d2a7d88.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Input/Gestures/GestureConfigFlick.cs:28
/// Configuration class for the Flick gesture.
/// </summary>
/// <remarks>A Flick gesture can be composed of 1 or more fingers.</remarks>
public sealed class GestureConfigFlick : GestureConfig
{
/// <summary>
/// The (x,y) error margins allowed during directional dragging.
/// </summary>
/// <exception cref="InvalidOperationException">Tried to modify the configuration after it has been frozen by the system.</exception>
/// <exception cref="ArgumentOutOfRangeException">The provided x or y value was not positive.</exception>
public Vector2 AllowedErrorMargins
{
get { return allowedErrorMargins; }
set
{
CheckNotFrozen();
if (value.X < 0 || value.Y < 0)
throw new ArgumentOutOfRangeException("value");
allowedErrorMargins = value;
}
}
private Vector2 allowedErrorMargins;
/// <summary>
/// The shape of the flick gesture.
/// </summary>
/// <exception cref="InvalidOperationException">Tried to modify the configuration after it has been frozen by the system.</exception>
public GestureShape FlickShape
{
get { return flickShape; }
set
{
CheckNotFrozen();
flickShape = value;View on GitHub (pinned to 96fad776d2)