WriteError.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* Copyright 2010-present 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 System.Collections.Generic;
  17. using System.Collections.ObjectModel;
  18. using System.Linq;
  19. using MongoDB.Bson;
  20. using MongoDB.Bson.Serialization.Attributes;
  21. using MongoDB.Driver.Support;
  22. namespace MongoDB.Driver
  23. {
  24. /// <summary>
  25. /// Represents the details of a write error.
  26. /// </summary>
  27. #if NET452
  28. [Serializable]
  29. #endif
  30. public class WriteError
  31. {
  32. // private fields
  33. private readonly ServerErrorCategory _category;
  34. private readonly int _code;
  35. private readonly BsonDocument _details;
  36. private readonly string _message;
  37. // constructors
  38. internal WriteError(ServerErrorCategory category, int code, string message, BsonDocument details)
  39. {
  40. _category = category;
  41. _code = code;
  42. _details = details;
  43. _message = message;
  44. }
  45. // public properties
  46. /// <summary>
  47. /// Gets the category.
  48. /// </summary>
  49. public ServerErrorCategory Category
  50. {
  51. get { return _category; }
  52. }
  53. /// <summary>
  54. /// Gets the error code.
  55. /// </summary>
  56. public int Code
  57. {
  58. get { return _code; }
  59. }
  60. /// <summary>
  61. /// Gets the error details.
  62. /// </summary>
  63. public BsonDocument Details
  64. {
  65. get { return _details; }
  66. }
  67. /// <summary>
  68. /// Gets the error message.
  69. /// </summary>
  70. public string Message
  71. {
  72. get { return _message; }
  73. }
  74. }
  75. }