PageRenderTime 44ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Mercurial.Net/MercurialExecutionException.cs

#
C# | 136 lines | 50 code | 9 blank | 77 comment | 0 complexity | fbe4440f5565ee66b0955a225066a445 MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0
  1. using System;
  2. using System.Runtime.Serialization;
  3. using System.Security.Permissions;
  4. namespace Mercurial
  5. {
  6. /// <summary>
  7. /// Represents errors related to Mercurial.
  8. /// </summary>
  9. [Serializable]
  10. public class MercurialExecutionException : MercurialException
  11. {
  12. /// <summary>
  13. /// This is the backing field for the <see cref="ExitCode"/> property.
  14. /// </summary>
  15. private readonly int _ExitCode;
  16. /// <summary>
  17. /// Initializes a new instance of the <see cref = "MercurialExecutionException" /> class.
  18. /// </summary>
  19. /// <param name="info">The <see cref = "T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
  20. /// <param name="context">The <see cref = "T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
  21. /// <exception cref = "T:System.ArgumentNullException">
  22. /// The <paramref name = "info" /> parameter is null.
  23. /// </exception>
  24. /// <exception cref = "T:System.Runtime.Serialization.SerializationException">
  25. /// The class name is null or <see cref = "P:System.Exception.HResult" /> is zero (0).
  26. /// </exception>
  27. protected MercurialExecutionException(SerializationInfo info, StreamingContext context)
  28. : base(info, context)
  29. {
  30. _ExitCode = info.GetInt32("_ExitCode");
  31. }
  32. /// <summary>
  33. /// Initializes a new instance of the <see cref = "MercurialExecutionException" /> class.
  34. /// </summary>
  35. public MercurialExecutionException()
  36. {
  37. // Do nothing here
  38. }
  39. /// <summary>
  40. /// Initializes a new instance of the <see cref = "MercurialExecutionException" /> class
  41. /// with a specific error message.
  42. /// </summary>
  43. /// <param name="message">The message.</param>
  44. public MercurialExecutionException(string message)
  45. : base(message)
  46. {
  47. // Do nothing here
  48. }
  49. /// <summary>
  50. /// Initializes a new instance of the <see cref = "MercurialExecutionException" /> class
  51. /// with a specific error message.
  52. /// </summary>
  53. /// <param name="exitCode">
  54. /// The exit code from executing the Mercurial command line client executable.
  55. /// </param>
  56. /// <param name="message">The message.</param>
  57. public MercurialExecutionException(int exitCode, string message)
  58. : base(message)
  59. {
  60. _ExitCode = exitCode;
  61. }
  62. /// <summary>
  63. /// Initializes a new instance of the <see cref = "MercurialExecutionException" /> class
  64. /// s with a specified error message and a reference to the inner exception
  65. /// that is the cause of this exception.
  66. /// </summary>
  67. /// <param name="message">
  68. /// The error message that explains the reason for the exception.
  69. /// </param>
  70. /// <param name="innerException">
  71. /// The exception that is the cause of the current exception,
  72. /// or a <c>null</c> reference (<c>Nothing</c> in Visual Basic)
  73. /// if no inner exception is specified.
  74. /// </param>
  75. public MercurialExecutionException(string message, Exception innerException)
  76. : base(message, innerException)
  77. {
  78. }
  79. /// <summary>
  80. /// Initializes a new instance of the <see cref = "MercurialExecutionException" /> class
  81. /// s with a specified error message and a reference to the inner exception
  82. /// that is the cause of this exception.
  83. /// </summary>
  84. /// <param name="exitCode">
  85. /// The exit code from executing the Mercurial command line client executable.
  86. /// </param>
  87. /// <param name="message">
  88. /// The error message that explains the reason for the exception.
  89. /// </param>
  90. /// <param name="innerException">
  91. /// The exception that is the cause of the current exception,
  92. /// or a <c>null</c> reference (<c>Nothing</c> in Visual Basic)
  93. /// if no inner exception is specified.
  94. /// </param>
  95. public MercurialExecutionException(int exitCode, string message, Exception innerException)
  96. : base(message, innerException)
  97. {
  98. _ExitCode = exitCode;
  99. }
  100. /// <summary>
  101. /// Gets the exit code of the process that was executed and failed.
  102. /// </summary>
  103. public int ExitCode
  104. {
  105. get
  106. {
  107. return _ExitCode;
  108. }
  109. }
  110. /// <summary>
  111. /// When overridden in a derived class, sets the <see cref = "T:System.Runtime.Serialization.SerializationInfo" /> with information about the exception.
  112. /// </summary>
  113. /// <param name="info">The <see cref = "T:System.Runtime.Serialization.SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
  114. /// <param name="context">The <see cref = "T:System.Runtime.Serialization.StreamingContext" /> that contains contextual information about the source or destination.</param>
  115. /// <exception cref = "T:System.ArgumentNullException">The <paramref name = "info" /> parameter is a null reference (Nothing in Visual Basic). </exception>
  116. /// <PermissionSet>
  117. /// <IPermission class = "System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version = "1" Read = "*AllFiles*" PathDiscovery = "*AllFiles*" />
  118. /// <IPermission class = "System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version = "1" Flags = "SerializationFormatter" />
  119. /// </PermissionSet>
  120. [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
  121. public override void GetObjectData(SerializationInfo info, StreamingContext context)
  122. {
  123. base.GetObjectData(info, context);
  124. info.AddValue("_ExitCode", ExitCode);
  125. }
  126. }
  127. }