{"record":{"id":"9711184956ca22a4","repo":"AvaloniaUI/Avalonia","slug":"bindingerrortype-may-not-be-none","errorCode":null,"errorMessage":"BindingErrorType may not be None","messagePattern":"BindingErrorType may not be None","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Data/BindingNotification.cs","lineNumber":245,"sourceCode":"        /// Gets the hash code for this instance of <see cref=\"BindingNotification\"/>. \n        /// </summary>\n        /// <returns>A hash code.</returns>\n        public override int GetHashCode()\n        {\n            return base.GetHashCode();\n        }\n\n        /// <summary>\n        /// Adds an error to the <see cref=\"BindingNotification\"/>.\n        /// </summary>\n        /// <param name=\"e\">The error to add.</param>\n        /// <param name=\"type\">The error type.</param>\n        public void AddError(Exception e, BindingErrorType type)\n        {\n            _ = e ?? throw new ArgumentNullException(nameof(e));\n\n            if (type == BindingErrorType.None)\n                throw new ArgumentException(\"BindingErrorType may not be None\", nameof(type));\n\n            Error = Error != null ? new AggregateException(Error, e) : e;\n\n            if (type == BindingErrorType.Error || ErrorType == BindingErrorType.Error)\n            {\n                ErrorType = BindingErrorType.Error;\n            }\n        }\n\n        /// <summary>\n        /// Removes the <see cref=\"Value\"/> and makes <see cref=\"HasValue\"/> return null.\n        /// </summary>\n        public void ClearValue()\n        {\n            _value = AvaloniaProperty.UnsetValue;\n        }\n\n        /// <summary>","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Data/BindingNotification.cs#L227-L263","documentation":"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'.","triggerScenarios":"Calling notification.AddError(e, BindingErrorType.None). The method requires a real error type to classify the aggregated exception.","commonSituations":"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.","solutions":["Filter out or skip BindingErrorType.None entries before calling AddError.","Ensure the error type passed is Error or DataValidationError, never None.","If no real error exists, do not call AddError at all."],"exampleFix":"// before\nforeach (var (e, t) in errors)\n    notification.AddError(e, t); // throws when t == None\n// after\nforeach (var (e, t) in errors)\n    if (t != BindingErrorType.None)\n        notification.AddError(e, t);","handlingStrategy":"validation","validationCode":"if (type != BindingErrorType.None)\n    notification.AddError(e, type);","typeGuard":null,"tryCatchPattern":"try { notification.AddError(e, type); }\ncatch (ArgumentException ex) when (ex.ParamName == \"type\")\n{ /* skip None errors */ }","preventionTips":["Filter out BindingErrorType.None before calling AddError.","Initialize BindingErrorType fields to a real value, never rely on default None.","Unit-test error-accumulation loops with mixed types."],"tags":["binding","bindingnotification","validation","data"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}