WriteConcernError.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* Copyright 2010-2016 MongoDB Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. using System;
  16. using MongoDB.Bson;
  17. namespace MongoDB.Driver
  18. {
  19. /// <summary>
  20. /// Represents the details of a write concern error.
  21. /// </summary>
  22. #if NET45
  23. [Serializable]
  24. #endif
  25. public class WriteConcernError
  26. {
  27. // private fields
  28. private readonly int _code;
  29. private readonly BsonDocument _details;
  30. private readonly string _message;
  31. // constructors
  32. internal WriteConcernError(int code, string message, BsonDocument details)
  33. {
  34. _code = code;
  35. _details = details;
  36. _message = message;
  37. }
  38. // public properties
  39. /// <summary>
  40. /// Gets the error code.
  41. /// </summary>
  42. public int Code
  43. {
  44. get { return _code; }
  45. }
  46. /// <summary>
  47. /// Gets the error information.
  48. /// </summary>
  49. public BsonDocument Details
  50. {
  51. get { return _details; }
  52. }
  53. /// <summary>
  54. /// Gets the error message.
  55. /// </summary>
  56. public string Message
  57. {
  58. get { return _message; }
  59. }
  60. // internal static methods
  61. internal static WriteConcernError FromCore(Core.Operations.BulkWriteConcernError error)
  62. {
  63. return error == null ? null : new WriteConcernError(error.Code, error.Message, error.Details);
  64. }
  65. }
  66. }