System.Windows.Data.BindingExpressionBase.MaybeEmitError C# (CSharp) Method

MaybeEmitError() private method

private MaybeEmitError ( object message, Exception exception ) : void
message object
exception Exception
return void
		void MaybeEmitError (object message, Exception exception)
		{
			var fe = Target as FrameworkElement;
			if (!Binding.NotifyOnValidationError || fe == null) {
				return;
			}

			if (message is string && (string) message == "")
				message = null;

			var oldError = CurrentError;
			if (message != null)
				CurrentError = new ValidationError (message, null);
			else if (exception != null)
				CurrentError = new ValidationError (null, exception);
			else
				CurrentError = null;

			// We had an error and now we have a new error
			if (oldError != null && CurrentError != null) {
				Validation.AddError (fe, CurrentError);
				Validation.RemoveError (fe, oldError);
				fe.RaiseBindingValidationError (new ValidationErrorEventArgs(ValidationErrorEventAction.Removed, oldError));
				fe.RaiseBindingValidationError (new ValidationErrorEventArgs(ValidationErrorEventAction.Added, CurrentError));
			} else if (oldError != null) {
				Validation.RemoveError (fe, oldError);
				fe.RaiseBindingValidationError (new ValidationErrorEventArgs(ValidationErrorEventAction.Removed, oldError));
			} else if (CurrentError != null) {
				Validation.AddError (fe, CurrentError);
				fe.RaiseBindingValidationError (new ValidationErrorEventArgs(ValidationErrorEventAction.Added, CurrentError));
			}
		}