/// <summary> /// Removes the error from the model's collection of errors. /// </summary> /// <param name="theError">The error to be removed from the model.</param> public void RemoveError(IModelError theError) { m_modelErrors.Remove(theError); if (ErrorCleared != null) { ErrorCleared(theError); } }
/// <summary> /// Removes the error from the model's collection of errors. /// </summary> /// <param name="theError">The error to be removed from the model.</param> public void RemoveError(IModelError theError) { if (s_diagnostics) { _Debug.WriteLine("Removing error " + theError.Narrative); } m_errors.Remove(theError.Target, theError); if (ErrorCleared != null) { ErrorCleared(theError); } }
/// <summary> /// Adds an error to the model, and iterates over all of the error handlers, /// allowing each in turn to respond to the error. As soon as any errorHandler /// indicates that it has HANDLED the error (by returning true from 'HandleError'), /// the error is cleared, and further handlers are not called. /// </summary> /// <param name="theError">The error that is to be added to the model's error list.</param> /// <returns>True if the error was successfully added to the model, false if it was cleared by a handler.</returns> public bool AddError(IModelError theError) { foreach (IErrorHandler errorHandler in ErrorHandlers) { if (errorHandler.HandleError(theError)) { if (ErrorCleared != null) { ErrorCleared(theError); } return(false); } } if (theError.Target == null) { throw new ApplicationException("An error was added to the model with its target set to null. This is illegal."); } m_errors.Add(theError.Target, theError); if (ErrorHappened != null) { ErrorHappened(theError); } // IF WE ARE TRANSITIONING, We are not going to abort on the // addition of an error, since there may be intermediate situations // where an error is okay. If a 'fail on the first sign of an error' // behavior is desired, then the developer can hook the // 'ErrorHappened' event. Instead, we will have the model register a // handler as the last thing done on attempting a transition, to // check that we are error-free. But, IF WE ARE NOT TRANSITIONING, // then anything that causes an error will abort the model, and move // it back to the 'Idle' state. if (!StateMachine.IsTransitioning) { if (s_diagnostics) { _Debug.WriteLine("Model.Abort() requested as a result of the addition of an error : " + theError); } if (!StateMachine.State.Equals(GetAbortEnum())) { StateMachine.DoTransition(GetAbortEnum()); } } return(true); }
/// <summary> /// Adds an error to the model, and iterates over all of the error handlers, /// allowing each in turn to respond to the error. As soon as any errorHandler /// indicates that it has HANDLED the error (by returning true from 'HandleError'), /// the error is cleared, and further handlers are not called. /// </summary> /// <param name="theError">The error that is to be added to the model's error list.</param> /// <returns> /// True if the error was successfully added to the model, false if it was cleared by a handler. /// </returns> public bool AddError(IModelError theError) { foreach (IErrorHandler ieh in m_errorHandlers) { if (ieh.HandleError(theError)) { return(false); } } m_modelErrors.Add(theError); if (ErrorHappened != null) { ErrorHappened(theError); } return(true); }
private void Model_ErrorCleared(IModelError modelError) { _Debug.WriteLine(Executive.Now + " : ERROR CLEARED : " + modelError.Narrative); }
private void Model_ErrorHappened(IModelError modelError) { _Debug.WriteLine(Executive.Now + " : ERROR HAPPENED : " + modelError.Narrative); }