Re: Exception handling?
Hi Goran,
Got a little bit of logic only stuff here for you that I tried on my work
break, but I won't be able to fully clean up my code till I get home tonight.
(First off, I rather poorly worded the "user" exception part,
hopefully you understood (seems so).)
Ugh well, somethings I understood, others I am still tearing
down my ignorance piece by piece
I've learned so far (from the Debugger) that I don't seem
to need to catch any exceptions other than my own.
Not even that. Why do you think that? (That is, show an example,
let's discuss it).
Ugh, well if I don't code any exception handlers at all in my code,
and I step thru the serial read (on a file I have made sure is corrupt),
it takes me to and end of file handler which does all of what I previously
said. So I would think that at least the reading past end of file looking for
stuff ( resulting from grabbing "prewritten length" bytes where they are
supposed to be, but were not ) would be covered without me coding any
exception handler.
Your question makes me feel I still have not conceptualized this
area enough yet.
Additionally I have this logic going so far.
// in the read loop of MyDoc class serialize
else
{
try
{
ar >> FID_Read;; // DWORD FID_Read;
if (FID_Read != FileID) // const DWORD FileID;
{ // FileID mismatch
throw new CWrongFileIDException();
}
ar >> VerData.Ver >> VerData.CpyRt >> VerData.Corp;
ar.SerializeClass(RUNTIME_CLASS(CMapStringToString));
ExpMap1.Serialize(ar);
}
catch(CWrongFileIDException* e)
{
// Do whatever I may need here
// so far nothing that I can tell, in fact it seems I could have just
// eliminated my try and catch handlers and just called the
// AfxThrowArchiveException in the if loop above ?
e->Delete( );
AfxThrowArchiveException(CArchiveException::badIndex, NULL ); //Invalid file format
// The above takes me to the exact same cleanup code that I get when
// I read in a corrupt file (with NO exception code at all ) and mfc handlers it.
// And leaves me with an untitled filename eliminating the change if inadvertant
// save overwrite.
}
}