public static ConfigStoreFault ToFault(Exception ex)
        {
            ConfigStoreException ce = ex as ConfigStoreException;

            if (ce != null)
            {
                return(ce.ToFault());
            }

            ChangeConflictException conflict = ex as ChangeConflictException;

            if (conflict != null)
            {
                return(new ConfigStoreFault(ConfigStoreError.Conflict, conflict.Message));
            }

            SqlException sqlex = ex as SqlException;

            if (sqlex != null)
            {
                ConfigStoreError errorCode = ConfigStoreError.DatabaseError;
                switch (sqlex.Number)
                {
                default:
                    break;

                case (int)SqlErrorCodes.DuplicatePrimaryKey:
                case (int)SqlErrorCodes.UniqueConstraintViolation:
                    errorCode = ConfigStoreError.UniqueConstraint;
                    break;

                case (int)SqlErrorCodes.ForeignKeyViolation:
                    errorCode = ConfigStoreError.ForeignKeyConstraint;
                    break;
                }

                return(new ConfigStoreFault(errorCode, sqlex.Message));
            }

            DbException dbex = ex as DbException;

            if (dbex != null)
            {
                return(new ConfigStoreFault(ConfigStoreError.DatabaseError, dbex.Message));
            }

            return(new ConfigStoreFault(ConfigStoreError.Unknown, ex.Message));
        }
 public ConfigStoreFault(ConfigStoreError error, string message)
 {
     this.Error   = error;
     this.Message = message;
 }
 public ConfigStoreFault(ConfigStoreError error)
     : this(error, null)
 {
 }