Re: VC++ Runtime Error
(facepalm) As per Ivor Horton's Beginning Visual C++ 6:
"There is one slight anomaly you need to keep in mind when we come to
using MFC functions that throw exceptions. The MFC functions that
throw exceptions, generally throw exceptions of class types [...]
Even though the exception that an MFC function throws is of a given
class type [...] you need to catch the exception as a pointer, not as
the type of exception."
Code now changed to:
try
{
pHttpFile = (CHttpFile *) mySession.OpenURL(RSSURL, 1,
INTERNET_FLAG_TRANSFER_ASCII | INTERNET_FLAG_RELOAD, NULL, 0);
}
catch (CInternetException* iErr)
{
GetDlgItem(IDC_EDIT_ERROR)->SetWindowText("There is a problem
connecting to server. Check connection.");
iErr->Delete();
mySession.Close();
return;
}
GetDlgItem(IDC_EDIT_ERROR)->SetWindowText(""); // clear error if we
make it past the OpenURL code.
It looks like this solved my problem. On unplugging the network
cable, it now displays the appropriate error message and upon
reestablishing the connection, the error disappears and the software
continues to read the feed. I'm going to do some more testing on the
prototype to make sure that this solves the original problem that
occured naturally, but I think it will.
Thanks for you comments, all.