AvaloniaUI/Avalonia · error · ArgumentException

BindingErrorType may not be None

Error message

BindingErrorType may not be None

What it means

Thrown as ArgumentException by BindingNotification.AddError(Exception, BindingErrorType) when the type argument is BindingErrorType.None. AddError aggregates errors and None (meaning 'no error') is not a valid error to add. The paramName is 'type'.

Source

Thrown at src/Avalonia.Base/Data/BindingNotification.cs:245

        /// Gets the hash code for this instance of <see cref="BindingNotification"/>. 
        /// </summary>
        /// <returns>A hash code.</returns>
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        /// <summary>
        /// Adds an error to the <see cref="BindingNotification"/>.
        /// </summary>
        /// <param name="e">The error to add.</param>
        /// <param name="type">The error type.</param>
        public void AddError(Exception e, BindingErrorType type)
        {
            _ = e ?? throw new ArgumentNullException(nameof(e));

            if (type == BindingErrorType.None)
                throw new ArgumentException("BindingErrorType may not be None", nameof(type));

            Error = Error != null ? new AggregateException(Error, e) : e;

            if (type == BindingErrorType.Error || ErrorType == BindingErrorType.Error)
            {
                ErrorType = BindingErrorType.Error;
            }
        }

        /// <summary>
        /// Removes the <see cref="Value"/> and makes <see cref="HasValue"/> return null.
        /// </summary>
        public void ClearValue()
        {
            _value = AvaloniaProperty.UnsetValue;
        }

        /// <summary>

View on GitHub (pinned to 11c5427268)

Solutions

  1. Filter out or skip BindingErrorType.None entries before calling AddError.
  2. Ensure the error type passed is Error or DataValidationError, never None.
  3. If no real error exists, do not call AddError at all.

Example fix

// before
foreach (var (e, t) in errors)
    notification.AddError(e, t); // throws when t == None
// after
foreach (var (e, t) in errors)
    if (t != BindingErrorType.None)
        notification.AddError(e, t);
Defensive patterns

Strategy: validation

Validate before calling

if (type != BindingErrorType.None)
    notification.AddError(e, type);

Try / catch

try { notification.AddError(e, type); }
catch (ArgumentException ex) when (ex.ParamName == "type")
{ /* skip None errors */ }

Prevention

When it happens

Trigger: Calling notification.AddError(e, BindingErrorType.None). The method requires a real error type to classify the aggregated exception.

Common situations: Loop/accumulator code that adds errors from a collection where some entries default to None. Conditional logic selecting an error type with a None fallback. Reusing a BindingErrorType field that was never initialized away from its default.

Related errors


AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13). Data as JSON: /api/errors/9711184956ca22a4. Report an issue: GitHub.