PageRenderTime 18ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Mercurial.Net/MercurialExecutionException.cs

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