/// <summary> /// Private constructor used by all public constructors. /// </summary> /// <param name="message">The localized error message</param> /// <param name="innerException">Optional inner exception.</param> /// <param name="status">status of the exception</param> /// <param name="errorCode">custom error code</param> /// <param name="stackTrace">stack trace of the exception</param> /// <param name="validationErrors">validation errror of the exception</param> protected DomainOperationException(string message, Exception innerException, OperationErrorStatus status, int errorCode, string stackTrace, IEnumerable <ValidationResult> validationErrors) : base(message, innerException) { Debug.Assert(!innerException.IsFatal(), "Fatal exception passed in as InnerException"); this._data.Status = status; this._data.StackTrace = stackTrace; this._data.ErrorCode = errorCode; // Iterate the enumerable now in order to capture the validation errors at the moment the exception is created if (validationErrors != null) { this._data.ValidationResults = new ReadOnlyCollection <ValidationResult>(validationErrors.ToList()); } #if !SILVERLIGHT // TODO: uncomment when CLR fixes 851783 //// The new CLR 4.0 safe serialization model accepts custom data through //// this pattern. We are called back during serialization to provide //// our custom data. //SerializeObjectState += delegate(object exception, SafeSerializationEventArgs eventArgs) //{ // eventArgs.AddSerializedState(this._data); //}; #endif }
/// <summary> /// Private constructor used by all public constructors. /// </summary> /// <param name="changeSet">the changeset being submitted</param> /// <param name="message">The localized error message</param> /// <param name="innerException">Optional inner exception.</param> /// <param name="status">status of the exception</param> /// <param name="errorCode">custom error code</param> /// <param name="stackTrace">stack trace of the exception</param> private SubmitOperationException(EntityChangeSet changeSet, string message, Exception innerException, OperationErrorStatus status, int errorCode, string stackTrace) : base(message, innerException, status, errorCode, stackTrace, GetValidationResults(changeSet)) { _changeSet = changeSet; _entitiesInError = new ReadOnlyCollection<Entity>(changeSet .Where(p => p.EntityConflict != null || p.HasValidationErrors) .ToList()); }
internal void Complete(OperationErrorStatus errorStatus) { SubmitOperationException error = null; if (errorStatus == OperationErrorStatus.ValidationFailed) { error = new SubmitOperationException(ChangeSet, Resource.DomainContext_SubmitOperationFailed_Validation, OperationErrorStatus.ValidationFailed); } else if (errorStatus == OperationErrorStatus.Conflicts) { error = new SubmitOperationException(ChangeSet, Resource.DomainContext_SubmitOperationFailed_Conflicts, OperationErrorStatus.Conflicts); } base.Complete(error); }
internal void Complete(OperationErrorStatus errorStatus) { SubmitOperationException error = null; if (errorStatus == OperationErrorStatus.ValidationFailed) { error = new SubmitOperationException(ChangeSet, Resource.DomainContext_SubmitOperationFailed_Validation, OperationErrorStatus.ValidationFailed); } else if (errorStatus == OperationErrorStatus.Conflicts) { error = new SubmitOperationException(ChangeSet, Resource.DomainContext_SubmitOperationFailed_Conflicts, OperationErrorStatus.Conflicts); } else { // This can never happen, all paths here supply either // ValidationFailed or Conflicts throw new ArgumentException("Unsupported OperationErrorStatus", nameof(errorStatus)); } base.Complete(error); }
/// <summary> /// Private constructor used by all public constructors. /// </summary> /// <param name="changeSet">the changeset being submitted</param> /// <param name="message">The localized error message</param> /// <param name="innerException">Optional inner exception.</param> /// <param name="status">status of the exception</param> /// <param name="errorCode">custom error code</param> /// <param name="stackTrace">stack trace of the exception</param> private SubmitOperationException(EntityChangeSet changeSet, string message, Exception innerException, OperationErrorStatus status, int errorCode, string stackTrace) : base(message, innerException, status, errorCode, stackTrace, GetValidationResults(changeSet)) { _changeSet = changeSet; }
/// <summary> /// Constructor that accepts a localized exception message and status /// </summary> /// <param name="changeSet">the changeset being submitted</param> /// <param name="message">The localized exception message</param> /// <param name="status">The status of the exception</param> public SubmitOperationException(EntityChangeSet changeSet, string message, OperationErrorStatus status) : this(changeSet, message, /*innerException*/ null, status, /*errorCode*/ 0, /*stackTrace*/ null) { _changeSet = changeSet; }
/// <summary> /// Constructor that accepts a localized exception message, status and custom error code /// </summary> /// <param name="message">The localized exception message</param> /// <param name="status">The status of the exception</param> /// <param name="errorCode">The custom error code</param> public DomainOperationException(string message, OperationErrorStatus status, int errorCode) : this(message, /*innerException*/ null, status, errorCode, /*stackTrace*/ null, /*validationErrors*/ null) { }
/// <summary> /// Private constructor used by all public constructors. /// </summary> /// <param name="message">The localized error message</param> /// <param name="innerException">Optional inner exception.</param> /// <param name="status">status of the exception</param> /// <param name="errorCode">custom error code</param> /// <param name="stackTrace">stack trace of the exception</param> /// <param name="validationErrors">validation errror of the exception</param> protected DomainOperationException(string message, Exception innerException, OperationErrorStatus status, int errorCode, string stackTrace, IEnumerable<ValidationResult> validationErrors) : base(message, innerException) { Debug.Assert(!innerException.IsFatal(), "Fatal exception passed in as InnerException"); this._data.Status = status; this._data.StackTrace = stackTrace; this._data.ErrorCode = errorCode; // Iterate the enumerable now in order to capture the validation errors at the moment the exception is created if (validationErrors != null) this._data.ValidationResults = new ReadOnlyCollection<ValidationResult>(validationErrors.ToList()); #if !SILVERLIGHT // TODO: uncomment when CLR fixes 851783 //// The new CLR 4.0 safe serialization model accepts custom data through //// this pattern. We are called back during serialization to provide //// our custom data. //SerializeObjectState += delegate(object exception, SafeSerializationEventArgs eventArgs) //{ // eventArgs.AddSerializedState(this._data); //}; #endif }
/// <summary> /// Constructor accepting optional localized message, status, /// custom error code, stack trace of the exception and validation errors. /// </summary> /// <param name="message">The localized error message</param> /// <param name="status">status of the exception</param> /// <param name="errorCode">custom error code</param> /// <param name="stackTrace">stack trace of the exception</param> /// <param name="validationErrors">validation errror of the exception</param> public DomainOperationException(string message, OperationErrorStatus status, int errorCode, string stackTrace, IEnumerable<ValidationResult> validationErrors) : this(message, /*innerException*/ null, status, errorCode, stackTrace, /*validationErrors*/ validationErrors) { }
/// <summary> /// Private constructor used by all public constructors. /// </summary> /// <param name="changeSet">the changeset being submitted</param> /// <param name="message">The localized error message</param> /// <param name="innerException">Optional inner exception.</param> /// <param name="status">status of the exception</param> /// <param name="errorCode">custom error code</param> /// <param name="stackTrace">stack trace of the exception</param> private SubmitOperationException(EntityChangeSet changeSet, string message, Exception innerException, OperationErrorStatus status, int errorCode, string stackTrace) : base(message, innerException, status, errorCode, stackTrace, GetValidationResults(changeSet)) { _changeSet = changeSet; _entitiesInError = new ReadOnlyCollection <Entity>(changeSet .Where(p => p.EntityConflict != null || p.HasValidationErrors) .ToList()); }
/// <summary> /// Constructor accepting optional localized message, status, /// custom error code, stack trace of the exception and validation errors. /// </summary> /// <param name="message">The localized error message</param> /// <param name="status">status of the exception</param> /// <param name="errorCode">custom error code</param> /// <param name="stackTrace">stack trace of the exception</param> /// <param name="validationErrors">validation errror of the exception</param> public DomainOperationException(string message, OperationErrorStatus status, int errorCode, string stackTrace, IEnumerable <ValidationResult> validationErrors) : this(message, /*innerException*/ null, status, errorCode, stackTrace, /*validationErrors*/ validationErrors) { }
public OperationFailedException(string message, OperationErrorStatus status) : base(message) { Status = status; }