I want to define a custom exception that has two special properties: Field and FieldValue, and I want the message to be built from those two values in the exception constructor. Unfortunately the Message is read only.
This is what I have, but it still requires the message to be passed.
public class FieldFormatException: FormatException
{
private Fields _field;
private string _fieldValue;
public Fields Field{ get{ return _field; } }
public string FieldValue { get { return _value; } }
public FieldFormatException() : base() { }
private FieldFormatException(string message) { }
public FieldFormatException(string message, Fields field, string value):
base(message)
{
_fieldValue = value;
_field = field;
}
public FieldFormatException(string message, Exception inner, Fields field, string value):
base(message, inner)
{
_fieldValue = value;
_field = field;
}
protected FieldFormatException(System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context): base(info, context){}
}
How can I remove the Message as a parameter from the constructor, and then set the message based on the value of Field and FieldValue?