HandyOrg/HandyControl · error · ArgumentException

message

Error message

message

What it means

Verify.IsTrue(statement, name, message) throws ArgumentException(message, name) when the boolean condition is false, surfacing the caller-provided message. It is the standard precondition assertion of this Verify helper class.

Solutions

  1. Read the exception message and ParamName to see which condition failed; correct the argument.
  2. Re-check the API documentation for the asserted precondition.
  3. Validate inputs at your boundary before calling.

Example fix

// before
Verify.IsTrue(value > 0, nameof(value), "value must be positive"); // throws when value <= 0
// after
if (value <= 0) value = Math.Max(1, value);
Verify.IsTrue(value > 0, nameof(value), "value must be positive");
Defensive patterns

Strategy: validation

Validate before calling

if (!condition)
    throw new ArgumentException($"Precondition failed: {message}", nameof(value));

Try / catch

try { api.Call(value); }
catch (ArgumentException ex) when (ex.ParamName == nameof(value)) { /* read ex.Message for the failed condition */ }

Prevention

When it happens

Trigger: Calling an API whose implementation asserts a condition via Verify.IsTrue(cond, paramName, message) and the condition evaluates false (e.g. argument out of an allowed set, inconsistent parameter combination).

Common situations: Passing values that violate documented preconditions, refactoring that changed which values are legal, unit-test expectations diverging from library invariants.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of HandyOrg/HandyControl@2c0875ebd6 (2026-09-14). Data as JSON: /api/errors/f2f79be9ca9080bd. Report an issue: GitHub.

Appendix: source

Thrown at src/Shared/Microsoft.Windows.Shell/Standard/Verify.cs:125

    }

    [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
    [DebuggerStepThrough]
    public static void IsTrue(bool statement, string name)
    {
        if (!statement)
        {
            throw new ArgumentException("", name);
        }
    }

    [DebuggerStepThrough]
    [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
    public static void IsTrue(bool statement, string name, string message)
    {
        if (!statement)
        {
            throw new ArgumentException(message, name);
        }
    }

    [DebuggerStepThrough]
    [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
    public static void AreEqual<T>(T expected, T actual, string parameterName, string message)
    {
        if (expected == null)
        {
            if (actual != null && !actual.Equals(expected))
            {
                throw new ArgumentException(message, parameterName);
            }
        }
        else if (!expected.Equals(actual))
        {
            throw new ArgumentException(message, parameterName);
        }

View on GitHub (pinned to 2c0875ebd6)