
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Creating a New Exception Type
|
403
}
public RemoteComponentException(string message,
Exception innerException)
: base(message, innerException)
{
}
// Exception ctors that accept the new ServerName parameter
public RemoteComponentException(string message,
string serverName) : base(message)
{
this.serverName = serverName;
}
public RemoteComponentException(string message,
Exception innerException, string serverName)
: base(message, innerException)
{
this.serverName = serverName;
}
// Serialization ctor
public RemoteComponentException(SerializationInfo exceptionInfo,
StreamingContext exceptionContext)
: base(exceptionInfo, exceptionContext)
{
this.serverName = exceptionInfo.GetString("ServerName");
}
// Read-only property
public string ServerName
{
get{return (serverName.Trim( ));}
}
public override string Message
{
get
{
if (this.ServerName.Length == 0)
return (base.Message + Environment.NewLine +
"An unnamed server has encountered an error.");
else
return (base.Message + Environment.NewLine +
"The server " + this.ServerName +
" has encountered an error.");
}
}
// Overridden methods
// ToString method
Example 7-4. RemoteComponentException class (continued)