|
using System;
using System.Runtime.Serialization;
using System.Security.Permissions;
namespace Yap.Data.Client
{
/// <summary>
/// The exception that is thrown when an exception occurs during command execution.
/// </summary>
[Serializable]
public class CommandExecutionException : Exception
{
private readonly Command _Command;
/// <summary>
/// Gets the command that is the cause of exception.
/// </summary>
public Command Command
{
get { return _Command; }
}
/// <summary>
/// Initializes a new instance of the CommandExecutionException class using default property values.
/// </summary>
public CommandExecutionException() { }
/// <summary>
/// Initializes a new instance of the CommandExecutionException class with the specified error message.
/// </summary>
/// <param name="message">The message that describes the exception.</param>
public CommandExecutionException(String message) : base(message) { }
/// <summary>
/// Initializes a new instance of the CommandExecutionException class with the specified error message and a reference to the inner exception that is the cause of this exception.
/// </summary>
/// <param name="message">The message that describes the exception.</param>
/// <param name="inner">The exception that is the cause of the current exception.</param>
public CommandExecutionException(String message, Exception inner) : this(message, null, inner) { }
/// <summary>
/// Initializes a new instance of the CommandExecutionException class with the specified error message, command and a reference to the inner exception that is the cause of this exception.
/// </summary>
/// <param name="message">The message that describes the exception.</param>
/// <param name="command">The command that is the cause of exception.</param>
/// <param name="inner">The exception that is the cause of the current exception.</param>
public CommandExecutionException(String message, Command command, Exception inner)
: base(message, inner)
{
_Command = command;
}
/// <summary>
/// Initializes a new instance of the CommandExecutionException class with serialized data.
/// </summary>
/// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
protected CommandExecutionException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
_Command = (Command)info.GetValue("_Command", typeof(Command));
}
/// <summary>
/// When overridden in a derived class, sets the SerializationInfo with information about the exception.
/// </summary>
/// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue("_Command", _Command);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.