Commit 1236e152 authored by Jeremy Meng's avatar Jeremy Meng

Add FEATURE_SERIALIZATION constant.

parent a1e7ac2f
......@@ -17,7 +17,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DefineConstants>TRACE;DEBUG;FEATURE_SERIALIZATION</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
......@@ -27,7 +27,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE;FEATURE_SERIALIZATION</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
......
......@@ -11,22 +11,29 @@ namespace StackExchange.Redis
/// <summary>
/// Indicates that a command was illegal and was not sent to the server
/// </summary>
#if FEATURE_SERIALIZATION
[Serializable]
#endif
public sealed class RedisCommandException : Exception
{
#if FEATURE_SERIALIZATION
private RedisCommandException(SerializationInfo info, StreamingContext ctx) : base(info, ctx) { }
#endif
internal RedisCommandException(string message) : base(message) { }
internal RedisCommandException(string message, Exception innerException) : base(message, innerException) { }
}
/// <summary>
/// Indicates a connection fault when communicating with redis
/// </summary>
#if FEATURE_SERIALIZATION
[Serializable]
#endif
public sealed class RedisConnectionException : RedisException
{
#if FEATURE_SERIALIZATION
private RedisConnectionException(SerializationInfo info, StreamingContext ctx) : base(info, ctx)
{
this.FailureType = (ConnectionFailureType)info.GetInt32("failureType");
......@@ -39,6 +46,7 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
base.GetObjectData(info, context);
info.AddValue("failureType", (int)this.FailureType);
}
#endif
internal RedisConnectionException(ConnectionFailureType failureType, string message) : base(message)
{
......@@ -54,28 +62,36 @@ internal RedisConnectionException(ConnectionFailureType failureType, string mess
/// </summary>
public ConnectionFailureType FailureType { get; private set; }
}
/// <summary>
/// Indicates an issue communicating with redis
/// </summary>
#if FEATURE_SERIALIZATION
[Serializable]
#endif
public class RedisException : Exception
{
/// <summary>
/// Deserialization constructor; not intended for general usage
/// </summary>
#if FEATURE_SERIALIZATION
protected RedisException(SerializationInfo info, StreamingContext ctx) : base(info, ctx) { }
#endif
internal RedisException(string message) : base(message) { }
internal RedisException(string message, Exception innerException) : base(message, innerException) { }
}
/// <summary>
/// Indicates an exception raised by a redis server
/// </summary>
#if FEATURE_SERIALIZATION
[Serializable]
#endif
public sealed class RedisServerException : RedisException
{
#if FEATURE_SERIALIZATION
private RedisServerException(SerializationInfo info, StreamingContext ctx) : base(info, ctx) { }
#endif
internal RedisServerException(string message) : base(message) { }
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment