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
- Pass a meaningful BindingErrorType (Error or DataValidationError) when constructing the notification.
- If there is no error, do not create a BindingNotification at all — return AvaloniaProperty.UnsetValue or a normal value instead.
- 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
- Never construct a BindingNotification with BindingErrorType.None.
- If there is no error, return a normal value or UnsetValue instead.
- Guard errorType before construction.
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
- BindingErrorType may not be None
- Value must be less than 10.
- Give me 5 or more letter please :-)
- BindingValue has no value.
- Cannot add value to DoNothing binding value.
AI-assisted analysis of AvaloniaUI/Avalonia@11c5427268 (2026-08-13).
Data as JSON: /api/errors/2dd1b54ff81fd654.
Report an issue: GitHub.