I am trying to add a key value pair and having trouble adding the key to Exception.Data:
The enum is of type int (default)
catch (Exception ex)
{
ex.Data.Add(Enums.ExceptionData.SomeName, _someText);
}
note: when I add a watch for Enums.ExceptionData.SomeName, I get SomeName, the name of the enum back. for the line above when trying to add that as a key to the dictionary.
When I try to check the ex.Data further up the stack, it's returning null. Here's how I attempt to check it:
ex.Data[Enums.ExceptionData.SomeName].ToString()
So here's how it all goes down. First, in my Request.cs Abstract class, this code eventually runs (yes, _someText has a valid string):
try
{
// Send the Request
requestStream = request.GetRequestStream();
requestStream.Write(data, 0, data.Length);
requestStream.Close();
// get response
response = (HttpWebResponse)request.GetResponse();
}
catch (Exception ex)
{
// include SOAP string that was sent
ex.Data.Add(Enums.ExceptionDataRequest.SomeName, _someText);
string test;
}
In my code-behind I call this method:
try
{
radio.UpdateFrequency(...);
LogFrequency();
}
catch (Exception ex)
{
radio.LogFailure(..., ex.Data[Enums.ExceptionDataRequest.SomeName].ToString());
}
and here's how radio.UpdateFrequency looks:
public void UpdateFrequency(...)
{
....
// update frequency (which also performs opt-in)
FrequencyRequest request = new FrequencyRequest(actionID, email, listID);
FrequencyResponse response = (FrequencyResponse)request.SendRequest();
....
}
so if this fails, (at least believe) the request error bubbles up to my try/catch in my code-behind:
FrequencyRequest request = new FrequencyRequest(actionID, email, listID);
fails, now grab that data in my try-catch in my code-behind.