Exemple #1
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="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;
 }
Exemple #3
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;
 }
 /// <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));
     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="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);
         }
     }
 }
Exemple #9
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));
 }
 /// <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(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();
        }