/// <summary>
 /// Initializes a new instance of the <see cref="BulkWriteException"/> class.
 /// </summary>
 /// <param name="writeErrors">The write errors.</param>
 /// <param name="writeConcernError">The write concern error.</param>
 public BulkWriteException(
     IEnumerable <BulkWriteError> writeErrors,
     WriteConcernError writeConcernError)
     : base("A bulk write operation resulted in one or more errors.")
 {
     _writeErrors       = writeErrors.ToList();
     _writeConcernError = writeConcernError;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WriteException" /> class.
 /// </summary>
 /// <param name="writeError">The write error.</param>
 /// <param name="writeConcernError">The write concern error.</param>
 public WriteException(
     WriteError writeError,
     WriteConcernError writeConcernError)
     : base("A write operation resulted in an error.")
 {
     _writeError        = writeError;
     _writeConcernError = writeConcernError;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MongoBulkWriteException" /> class.
 /// </summary>
 /// <param name="connectionId">The connection identifier.</param>
 /// <param name="writeErrors">The write errors.</param>
 /// <param name="writeConcernError">The write concern error.</param>
 public MongoBulkWriteException(
     ConnectionId connectionId,
     IEnumerable <BulkWriteError> writeErrors,
     WriteConcernError writeConcernError)
     : base(connectionId, message: "A bulk write operation resulted in one or more errors.")
 {
     _writeErrors       = writeErrors.ToList();
     _writeConcernError = writeConcernError;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MongoBulkWriteException" /> class.
 /// </summary>
 /// <param name="connectionId">The connection identifier.</param>
 /// <param name="writeErrors">The write errors.</param>
 /// <param name="writeConcernError">The write concern error.</param>
 public MongoBulkWriteException(
     ConnectionId connectionId,
     IEnumerable <BulkWriteError> writeErrors,
     WriteConcernError writeConcernError)
     : base(connectionId, message: FormatMessage(writeErrors, writeConcernError))
 {
     _writeErrors       = writeErrors.ToList();
     _writeConcernError = writeConcernError;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MongoWriteException" /> class.
 /// </summary>
 /// <param name="connectionId">The connection identifier.</param>
 /// <param name="writeError">The write error.</param>
 /// <param name="writeConcernError">The write concern error.</param>
 /// <param name="innerException">The inner exception.</param>
 public MongoWriteException(
     ConnectionId connectionId,
     WriteError writeError,
     WriteConcernError writeConcernError,
     Exception innerException)
     : base(connectionId, FormatMessage(writeError, writeConcernError), innerException)
 {
     _writeError        = writeError;
     _writeConcernError = writeConcernError;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MongoWriteException" /> class.
 /// </summary>
 /// <param name="connectionId">The connection identifier.</param>
 /// <param name="writeError">The write error.</param>
 /// <param name="writeConcernError">The write concern error.</param>
 /// <param name="innerException">The inner exception.</param>
 public MongoWriteException(
     ConnectionId connectionId,
     WriteError writeError,
     WriteConcernError writeConcernError,
     Exception innerException)
     : base(connectionId, FormatMessage(writeError, writeConcernError), innerException)
 {
     _writeError = writeError;
     _writeConcernError = writeConcernError;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MongoWriteException" /> class.
 /// </summary>
 /// <param name="connectionId">The connection identifier.</param>
 /// <param name="writeError">The write error.</param>
 /// <param name="writeConcernError">The write concern error.</param>
 /// <param name="innerException">The inner exception.</param>
 public MongoWriteException(
     ConnectionId connectionId,
     WriteError writeError,
     WriteConcernError writeConcernError,
     Exception innerException)
     : base(connectionId, "A write operation resulted in an error.", innerException)
 {
     _writeError        = writeError;
     _writeConcernError = writeConcernError;
 }
Exemplo n.º 8
0
 // constructors
 /// <summary>
 /// Initializes a new instance of the <see cref="BulkWriteException" /> class.
 /// </summary>
 /// <param name="result">The result.</param>
 /// <param name="writeErrors">The write errors.</param>
 /// <param name="unprocessedRequests">The unprocessed requests.</param>
 /// <param name="writeConcernError">The write concern error.</param>
 public BulkWriteException(
     BulkWriteResult result, 
     IEnumerable<BulkWriteError> writeErrors,
     WriteConcernError writeConcernError,
     IEnumerable<WriteRequest> unprocessedRequests)
     : base("A bulk write operation resulted in one or more errors.")
 {
     _result = result;
     _writeErrors = new ReadOnlyCollection<BulkWriteError>(writeErrors.ToList());
     _writeConcernError = writeConcernError;
     _unprocessedRequests = new ReadOnlyCollection<WriteRequest>(unprocessedRequests.ToList());
 }
Exemplo n.º 9
0
 // constructors
 /// <summary>
 /// Initializes a new instance of the <see cref="BulkWriteException" /> class.
 /// </summary>
 /// <param name="result">The result.</param>
 /// <param name="writeErrors">The write errors.</param>
 /// <param name="unprocessedRequests">The unprocessed requests.</param>
 /// <param name="writeConcernError">The write concern error.</param>
 public BulkWriteException(
     BulkWriteResult result,
     IEnumerable <BulkWriteError> writeErrors,
     WriteConcernError writeConcernError,
     IEnumerable <WriteRequest> unprocessedRequests)
     : base("A bulk write operation resulted in one or more errors.")
 {
     _result              = result;
     _writeErrors         = new ReadOnlyCollection <BulkWriteError>(writeErrors.ToList());
     _writeConcernError   = writeConcernError;
     _unprocessedRequests = new ReadOnlyCollection <WriteRequest>(unprocessedRequests.ToList());
 }
 /// <summary>
 /// Initializes a new instance of the MongoQueryException class (this overload supports deserialization).
 /// </summary>
 /// <param name="info">The SerializationInfo.</param>
 /// <param name="context">The StreamingContext.</param>
 public MongoBulkWriteException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     _writeConcernError = (WriteConcernError)info.GetValue("_writeConcernError", typeof(WriteConcernError));
     _writeErrors       = (IReadOnlyList <BulkWriteError>)info.GetValue("_writeErrors", typeof(IReadOnlyList <BulkWriteError>));
     if (_writeConcernError != null)
     {
         foreach (var errorLabel in _writeConcernError.ErrorLabels)
         {
             AddErrorLabel(errorLabel);
         }
     }
 }
        // private static methods
        private static string FormatMessage(WriteError writeError, WriteConcernError writeConcernError)
        {
            var sb = new StringBuilder("A write operation resulted in an error.");

            if (writeError != null)
            {
                sb.AppendLine().Append("  " + writeError.Message);
            }
            if (writeConcernError != null)
            {
                sb.AppendLine().Append("  " + writeConcernError.Message);
            }

            return(sb.ToString());
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MongoBulkWriteException" /> class.
 /// </summary>
 /// <param name="connectionId">The connection identifier.</param>
 /// <param name="writeErrors">The write errors.</param>
 /// <param name="writeConcernError">The write concern error.</param>
 public MongoBulkWriteException(
     ConnectionId connectionId,
     IEnumerable <BulkWriteError> writeErrors,
     WriteConcernError writeConcernError)
     : base(connectionId, message: FormatMessage(writeErrors, writeConcernError))
 {
     _writeErrors       = writeErrors.ToList();
     _writeConcernError = writeConcernError;
     if (_writeConcernError != null)
     {
         foreach (var errorLabel in _writeConcernError.ErrorLabels)
         {
             AddErrorLabel(errorLabel);
         }
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MongoWriteException" /> class.
 /// </summary>
 /// <param name="connectionId">The connection identifier.</param>
 /// <param name="writeError">The write error.</param>
 /// <param name="writeConcernError">The write concern error.</param>
 /// <param name="innerException">The inner exception.</param>
 public MongoWriteException(
     ConnectionId connectionId,
     WriteError writeError,
     WriteConcernError writeConcernError,
     Exception innerException)
     : base(connectionId, FormatMessage(writeError, writeConcernError), innerException)
 {
     _writeError        = writeError;
     _writeConcernError = writeConcernError;
     if (_writeConcernError != null)
     {
         foreach (var errorLabel in _writeConcernError.ErrorLabels)
         {
             AddErrorLabel(errorLabel);
         }
     }
 }
Exemplo n.º 14
0
        // private static methods
        private static string FormatMessage(IEnumerable <BulkWriteError> writeErrors, WriteConcernError writeConcernError)
        {
            var sb = new StringBuilder("A bulk write operation resulted in one or more errors.");

            if (writeErrors != null)
            {
                foreach (var writeError in writeErrors)
                {
                    sb.AppendLine().Append("  " + writeError.Message);
                }
            }
            if (writeConcernError != null)
            {
                sb.AppendLine().Append("  " + writeConcernError.Message);
            }

            return(sb.ToString());
        }
Exemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the MongoQueryException class (this overload supports deserialization).
 /// </summary>
 /// <param name="info">The SerializationInfo.</param>
 /// <param name="context">The StreamingContext.</param>
 public MongoBulkWriteException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     _writeConcernError = (WriteConcernError)info.GetValue("_writeConcernError", typeof(WriteConcernError));
     _writeErrors       = (IReadOnlyList <BulkWriteError>)info.GetValue("_writeErrors", typeof(IReadOnlyList <BulkWriteError>));
 }
 private BulkWriteBatchResult CreateBatchResult(
     int? batchCount = null,
     int? requestCount = null,
     long? deletedCount = null,
     long? insertedCount = null,
     long? modifiedCount = null,
     long? updatedCount = null,
     IEnumerable<WriteRequest> processedRequests = null,
     IEnumerable<WriteRequest> unprocessedRequests = null,
     IEnumerable<BulkWriteUpsert> upserts = null,
     IEnumerable<BulkWriteError> writeErrors = null,
     WriteConcernError writeConcernError = null,
     IndexMap indexMap = null,
     Batch<WriteRequest> nextBatch = null)            
 {
     return new BulkWriteBatchResult(
         batchCount ?? 1,
         processedRequests ?? Enumerable.Empty<WriteRequest>(),
         unprocessedRequests ?? Enumerable.Empty<WriteRequest>(),
         deletedCount ?? 0,
         insertedCount ?? 0,
         modifiedCount ?? 0,
         updatedCount ?? 0,
         upserts ?? Enumerable.Empty<BulkWriteUpsert>(),
         writeErrors ?? Enumerable.Empty<BulkWriteError>(),
         writeConcernError,
         indexMap ?? IndexMap.IdentityMap,
         nextBatch);
 }
        // private static methods
        private static string FormatMessage(WriteError writeError, WriteConcernError writeConcernError)
        {
            var sb = new StringBuilder("A write operation resulted in an error.");
            if (writeError != null)
            {
                sb.AppendLine().Append("  " + writeError.Message);
            }
            if (writeConcernError != null)
            {
                sb.AppendLine().Append("  " + writeConcernError.Message);
            }

            return sb.ToString();
        }
 /// <summary>
 /// Initializes a new instance of the MongoQueryException class (this overload supports deserialization).
 /// </summary>
 /// <param name="info">The SerializationInfo.</param>
 /// <param name="context">The StreamingContext.</param>
 public MongoWriteException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     _writeConcernError = (WriteConcernError)info.GetValue("_writeConcernError", typeof(WriteConcernError));
     _writeError = (WriteError)info.GetValue("_writeError", typeof(WriteError));
 }
Exemplo n.º 19
0
 /// <summary>
 /// Initializes a new instance of the MongoQueryException class (this overload supports deserialization).
 /// </summary>
 /// <param name="info">The SerializationInfo.</param>
 /// <param name="context">The StreamingContext.</param>
 public MongoWriteException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     _writeConcernError = (WriteConcernError)info.GetValue("_writeConcernError", typeof(WriteConcernError));
     _writeError        = (WriteError)info.GetValue("_writeError", typeof(WriteError));
 }
        // private static methods
        private static string FormatMessage(IEnumerable <BulkWriteError> writeErrors, WriteConcernError writeConcernError)
        {
            var sb = new StringBuilder("A bulk write operation resulted in one or more errors.");

            if (writeErrors != null)
            {
                sb.Append(" WriteErrors: [ ");
                foreach (var writeError in writeErrors)
                {
                    sb.Append(writeError + ", ");
                }
                sb.Remove(sb.Length - 2, 2);
                sb.Append(" ].");
            }
            if (writeConcernError != null)
            {
                sb.Append($" WriteConcernError: {writeConcernError}.");
            }

            return(sb.ToString());
        }