GridFSMD5Exception.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* Copyright 2015-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. using MongoDB.Bson;
  20. using MongoDB.Driver.Core.Misc;
  21. namespace MongoDB.Driver.GridFS
  22. {
  23. /// <summary>
  24. /// Represents a GridFSMD5 exception.
  25. /// </summary>
  26. #if NET452
  27. [Serializable]
  28. #endif
  29. public class GridFSMD5Exception : GridFSException
  30. {
  31. #region static
  32. private static string FormatMessage(BsonValue id)
  33. {
  34. Ensure.IsNotNull(id, nameof(id));
  35. return string.Format("GridFS MD5 check failed: file id {0}.", id);
  36. }
  37. #endregion
  38. // constructors
  39. /// <summary>
  40. /// Initializes a new instance of the <see cref="GridFSMD5Exception"/> class.
  41. /// </summary>
  42. /// <param name="id">The file id.</param>
  43. public GridFSMD5Exception(BsonValue id)
  44. : base(FormatMessage(id))
  45. {
  46. }
  47. #if NET452
  48. /// <summary>
  49. /// Initializes a new instance of the <see cref="GridFSMD5Exception"/> class.
  50. /// </summary>
  51. /// <param name="info">The SerializationInfo.</param>
  52. /// <param name="context">The StreamingContext.</param>
  53. public GridFSMD5Exception(SerializationInfo info, StreamingContext context)
  54. : base(info, context)
  55. {
  56. }
  57. #endif
  58. }
  59. }