BsonException.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #if NET452
  17. using System.Runtime.Serialization;
  18. #endif
  19. namespace MongoDB.Bson
  20. {
  21. /// <summary>
  22. /// Represents a BSON exception.
  23. /// </summary>
  24. #if NET452
  25. [Serializable]
  26. #endif
  27. public class BsonException : Exception
  28. {
  29. // constructors
  30. /// <summary>
  31. /// Initializes a new instance of the BsonException class.
  32. /// </summary>
  33. public BsonException()
  34. : base()
  35. {
  36. }
  37. /// <summary>
  38. /// Initializes a new instance of the BsonException class.
  39. /// </summary>
  40. /// <param name="message">The error message.</param>
  41. public BsonException(string message)
  42. : base(message)
  43. {
  44. }
  45. /// <summary>
  46. /// Initializes a new instance of the BsonException class.
  47. /// </summary>
  48. /// <param name="message">The error message.</param>
  49. /// <param name="innerException">The inner exception.</param>
  50. public BsonException(string message, Exception innerException)
  51. : base(message, innerException)
  52. {
  53. }
  54. /// <summary>
  55. /// Initializes a new instance of the BsonException class.
  56. /// </summary>
  57. /// <param name="format">The error message format string.</param>
  58. /// <param name="args">One or more args for the error message.</param>
  59. public BsonException(string format, params object[] args)
  60. : base(string.Format(format, args))
  61. {
  62. }
  63. #if NET452
  64. /// <summary>
  65. /// Initializes a new instance of the BsonException class (this overload used by deserialization).
  66. /// </summary>
  67. /// <param name="info">The SerializationInfo.</param>
  68. /// <param name="context">The StreamingContext.</param>
  69. public BsonException(SerializationInfo info, StreamingContext context)
  70. : base(info, context)
  71. {
  72. }
  73. #endif
  74. }
  75. }