{"record":{"id":"2dd1b54ff81fd654","repo":"AvaloniaUI/Avalonia","slug":"errortype-may-not-be-none","errorCode":null,"errorMessage":"'errorType' may not be None","messagePattern":"'errorType' may not be None","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Data/BindingNotification.cs","lineNumber":72,"sourceCode":"        /// <summary>\n        /// Initializes a new instance of the <see cref=\"BindingNotification\"/> class.\n        /// </summary>\n        /// <param name=\"value\">The binding value.</param>\n        public BindingNotification(object? value)\n        {\n            _value = value;\n        }\n\n        /// <summary>\n        /// Initializes a new instance of the <see cref=\"BindingNotification\"/> class.\n        /// </summary>\n        /// <param name=\"error\">The binding error.</param>\n        /// <param name=\"errorType\">The type of the binding error.</param>\n        public BindingNotification(Exception error, BindingErrorType errorType)\n        {\n            if (errorType == BindingErrorType.None)\n            {\n                throw new ArgumentException($\"'errorType' may not be None\");\n            }\n\n            Error = error;\n            ErrorType = errorType;\n            _value = AvaloniaProperty.UnsetValue;\n        }\n\n        /// <summary>\n        /// Initializes a new instance of the <see cref=\"BindingNotification\"/> class.\n        /// </summary>\n        /// <param name=\"error\">The binding error.</param>\n        /// <param name=\"errorType\">The type of the binding error.</param>\n        /// <param name=\"fallbackValue\">The fallback value.</param>\n        public BindingNotification(Exception error, BindingErrorType errorType, object? fallbackValue)\n            : this(error, errorType)\n        {\n            _value = fallbackValue;\n        }","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Data/BindingNotification.cs#L54-L90","documentation":"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.).","triggerScenarios":"Constructing new BindingNotification(exception, BindingErrorType.None). Also reached via the 3-arg constructor (Exception, BindingErrorType, fallbackValue) which delegates to the 2-arg constructor.","commonSituations":"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'.","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."],"exampleFix":"// before\nvar n = new BindingNotification(ex, BindingErrorType.None); // throws\n// after\nvar n = new BindingNotification(ex, BindingErrorType.Error);","handlingStrategy":"validation","validationCode":"if (errorType == BindingErrorType.None)\n    return; // or return a plain value instead of a notification\nvar n = new BindingNotification(error, errorType);","typeGuard":null,"tryCatchPattern":"try { var n = new BindingNotification(error, errorType); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"None\"))\n{ /* skip creating the notification; there is no error */ }","preventionTips":["Never construct a BindingNotification with BindingErrorType.None.","If there is no error, return a normal value or UnsetValue instead.","Guard errorType before construction."],"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"}