AvaloniaUI/Avalonia · error · ArgumentException

'errorType' may not be None

Error message

'errorType' may not be None

What it means

Thrown as ArgumentException by the BindingNotification(Exception, BindingErrorType) constructor when errorType is BindingErrorType.None. BindingErrorType.None means 'no error', so constructing an error notification with it is contradictory and rejected. The notification must carry a real error type (Error, DataValidationError, etc.).

Source

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

        /// <summary>
        /// Initializes a new instance of the <see cref="BindingNotification"/> class.
        /// </summary>
        /// <param name="value">The binding value.</param>
        public BindingNotification(object? value)
        {
            _value = value;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="BindingNotification"/> class.
        /// </summary>
        /// <param name="error">The binding error.</param>
        /// <param name="errorType">The type of the binding error.</param>
        public BindingNotification(Exception error, BindingErrorType errorType)
        {
            if (errorType == BindingErrorType.None)
            {
                throw new ArgumentException($"'errorType' may not be None");
            }

            Error = error;
            ErrorType = errorType;
            _value = AvaloniaProperty.UnsetValue;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="BindingNotification"/> class.
        /// </summary>
        /// <param name="error">The binding error.</param>
        /// <param name="errorType">The type of the binding error.</param>
        /// <param name="fallbackValue">The fallback value.</param>
        public BindingNotification(Exception error, BindingErrorType errorType, object? fallbackValue)
            : this(error, errorType)
        {
            _value = fallbackValue;
        }

View on GitHub (pinned to 11c5427268)

Solutions

  1. Pass a meaningful BindingErrorType (Error or DataValidationError) when constructing the notification.
  2. If there is no error, do not create a BindingNotification at all — return AvaloniaProperty.UnsetValue or a normal value instead.
  3. Guard the error type variable before construction: if it is None, skip notification creation.

Example fix

// before
var n = new BindingNotification(ex, BindingErrorType.None); // throws
// after
var n = new BindingNotification(ex, BindingErrorType.Error);
Defensive patterns

Strategy: validation

Validate before calling

if (errorType == BindingErrorType.None)
    return; // or return a plain value instead of a notification
var n = new BindingNotification(error, errorType);

Try / catch

try { var n = new BindingNotification(error, errorType); }
catch (ArgumentException ex) when (ex.Message.Contains("None"))
{ /* skip creating the notification; there is no error */ }

Prevention

When it happens

Trigger: Constructing new BindingNotification(exception, BindingErrorType.None). Also reached via the 3-arg constructor (Exception, BindingErrorType, fallbackValue) which delegates to the 2-arg constructor.

Common situations: Custom binding/expression code that builds a BindingNotification but passes a default/uninitialized BindingErrorType. Logic that conditionally selects an error type and falls through to None. Porting code that conflated 'no error' with 'send notification'.

Related errors


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