Skip to content
Permalink
Browse files
Added serialization support to all NMS exceptions.
  • Loading branch information
Jim Gomes committed Feb 9, 2010
1 parent 6d95213 commit fd8a211c0b31c4d5d0f96dbced85627fce735bd0
Show file tree
Hide file tree
Showing 14 changed files with 270 additions and 6 deletions.
@@ -18,9 +18,11 @@
*/

using System;
using System.Runtime.Serialization;

namespace Apache.NMS
{
[Serializable]
public class IllegalStateException : NMSException
{
public IllegalStateException()
@@ -47,5 +49,21 @@ public IllegalStateException(string message, string errorCode, Exception innerEx
: base(message, errorCode, innerException)
{
}

#region ISerializable interface implementation

/// <summary>
/// Initializes a new instance of the IllegalStateException class with serialized data.
/// Throws System.ArgumentNullException if the info parameter is null.
/// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
/// </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 IllegalStateException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}

#endregion
}
}
@@ -18,9 +18,11 @@
*/

using System;
using System.Runtime.Serialization;

namespace Apache.NMS
{
[Serializable]
public class InvalidClientIDException : NMSException
{
public InvalidClientIDException()
@@ -47,5 +49,21 @@ public InvalidClientIDException(string message, string errorCode, Exception inne
: base(message, errorCode, innerException)
{
}

#region ISerializable interface implementation

/// <summary>
/// Initializes a new instance of the InvalidClientIDException class with serialized data.
/// Throws System.ArgumentNullException if the info parameter is null.
/// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
/// </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 InvalidClientIDException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}

#endregion
}
}
@@ -15,12 +15,14 @@
* limitations under the License.
*/
using System;
using System.Runtime.Serialization;

namespace Apache.NMS
{
/// <summary>
/// An attempt is made to access an invalid destination
/// </summary>
[Serializable]
public class InvalidDestinationException : NMSException
{
public InvalidDestinationException()
@@ -47,6 +49,22 @@ public InvalidDestinationException(string message, string errorCode, Exception i
: base(message, errorCode, innerException)
{
}

#region ISerializable interface implementation

/// <summary>
/// Initializes a new instance of the InvalidDestinationException class with serialized data.
/// Throws System.ArgumentNullException if the info parameter is null.
/// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
/// </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 InvalidDestinationException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}

#endregion
}
}

@@ -18,9 +18,11 @@
*/

using System;
using System.Runtime.Serialization;

namespace Apache.NMS
{
[Serializable]
public class InvalidSelectorException : NMSException
{
public InvalidSelectorException()
@@ -47,5 +49,21 @@ public InvalidSelectorException(string message, string errorCode, Exception inne
: base(message, errorCode, innerException)
{
}

#region ISerializable interface implementation

/// <summary>
/// Initializes a new instance of the InvalidSelectorException class with serialized data.
/// Throws System.ArgumentNullException if the info parameter is null.
/// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
/// </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 InvalidSelectorException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}

#endregion
}
}
@@ -18,9 +18,11 @@
*/

using System;
using System.Runtime.Serialization;

namespace Apache.NMS
{
[Serializable]
public class MessageEOFException : NMSException
{
public MessageEOFException()
@@ -47,5 +49,21 @@ public MessageEOFException(string message, string errorCode, Exception innerExce
: base(message, errorCode, innerException)
{
}

#region ISerializable interface implementation

/// <summary>
/// Initializes a new instance of the MessageEOFException class with serialized data.
/// Throws System.ArgumentNullException if the info parameter is null.
/// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
/// </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 MessageEOFException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}

#endregion
}
}
@@ -18,9 +18,11 @@
*/

using System;
using System.Runtime.Serialization;

namespace Apache.NMS
{
[Serializable]
public class MessageFormatException : NMSException
{
public MessageFormatException()
@@ -47,5 +49,21 @@ public MessageFormatException(string message, string errorCode, Exception innerE
: base(message, errorCode, innerException)
{
}

#region ISerializable interface implementation

/// <summary>
/// Initializes a new instance of the MessageFormatException class with serialized data.
/// Throws System.ArgumentNullException if the info parameter is null.
/// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
/// </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 MessageFormatException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}

#endregion
}
}
@@ -18,9 +18,11 @@
*/

using System;
using System.Runtime.Serialization;

namespace Apache.NMS
{
[Serializable]
public class MessageNotReadableException : NMSException
{
public MessageNotReadableException()
@@ -47,5 +49,21 @@ public MessageNotReadableException(string message, string errorCode, Exception i
: base(message, errorCode, innerException)
{
}

#region ISerializable interface implementation

/// <summary>
/// Initializes a new instance of the MessageNotReadableException class with serialized data.
/// Throws System.ArgumentNullException if the info parameter is null.
/// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
/// </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 MessageNotReadableException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}

#endregion
}
}
@@ -18,9 +18,11 @@
*/

using System;
using System.Runtime.Serialization;

namespace Apache.NMS
{
[Serializable]
public class MessageNotWriteableException : NMSException
{
public MessageNotWriteableException()
@@ -47,5 +49,21 @@ public MessageNotWriteableException(string message, string errorCode, Exception
: base(message, errorCode, innerException)
{
}

#region ISerializable interface implementation

/// <summary>
/// Initializes a new instance of the MessageNotWriteableException class with serialized data.
/// Throws System.ArgumentNullException if the info parameter is null.
/// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
/// </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 MessageNotWriteableException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}

#endregion
}
}
@@ -14,13 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using System;
using System.Runtime.Serialization;

namespace Apache.NMS
{
/// <summary>
/// Represents a connection failure.
/// </summary>
[Serializable]
public class NMSConnectionException : NMSException
{
public NMSConnectionException()
@@ -47,7 +50,21 @@ public NMSConnectionException(string message, string errorCode, Exception innerE
: base(message, errorCode, innerException)
{
}
}
}

#region ISerializable interface implementation

/// <summary>
/// Initializes a new instance of the NMSConnectionException class with serialized data.
/// Throws System.ArgumentNullException if the info parameter is null.
/// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
/// </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 NMSConnectionException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}

#endregion
}
}
@@ -16,13 +16,15 @@
*/

using System;
using System.Runtime.Serialization;

namespace Apache.NMS
{
/// <summary>
/// Represents a NMS exception
/// Represents an NMS exception
/// </summary>
public class NMSException : System.Exception
[Serializable]
public class NMSException : Exception
{
protected string exceptionErrorCode;

@@ -53,6 +55,37 @@ public NMSException(string message, string errorCode, Exception innerException)
exceptionErrorCode = errorCode;
}

#region ISerializable interface implementation

/// <summary>
/// Initializes a new instance of the NMSException class with serialized data.
/// Throws System.ArgumentNullException if the info parameter is null.
/// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
/// </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 NMSException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
exceptionErrorCode = info.GetString("NMSException.exceptionErrorCode");
}

/// <summary>
/// When overridden in a derived class, sets the SerializationInfo
/// with information about the exception.
/// </summary>
/// <param name="info">The System.Runtime.Serialization.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>
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue("NMSException.exceptionErrorCode", exceptionErrorCode);
}

#endregion

/// <summary>
/// Returns the error code for the exception, if one has been provided.
/// </summary>

0 comments on commit fd8a211

Please sign in to comment.