CArchive Exception Handeling

//code:

.void MyApp::readB(CArchive* ar){
. .int i,er;
. .wBody wB;
. .try{
. . .// don't worry about what this does:
. . .for (i=0;i<world.bodies;i++){
. . . .er = wB.Serialize(ar);
. . . .world.bodiesarr[i].fromWB(&wB);
. . .}
. . }
. . catch(CArchiveException *e){
. . .if (e->m_cause == CArchiveException::endOfFile){
. . . .//reset the archive, dont worry about this either though
. . . .CleanUpFileIO(ar,binFile);
. . . .InitBFile(fileB,fileI,true);
. . .}
. . .e->Delete();
. .}
.}

/*
The problem I am having is that when i have finished reading in the archive, I should catch the exception and get to the if(e->....) statement.
I placed a breakpoint on that line, and never hit it.
VC++ just spits out "CArchive Exception: end of file" in the debug window
over and over again (as this function is called from the main loop).
I need to get to the code inside the catch statement, and I am not sure why this program does not do so.
Thanks
- Derwin
*/

/* ps, here is code to cp and pst into compiler:
void MyApp::readB(CArchive* ar){
int i,er;
wBody wB;
try{
for (i=0;i<world.bodies;i++){
er = wB.Serialize(ar);
world.bodiesarr[i].fromWB(&wB);
}
}
catch(CArchiveException *e){
if (e->m_cause == CArchiveException::endOfFile){
CleanUpFileIO(ar,binFile);
InitBFile(fileB,fileI,true);
}
e->Delete();
}
}
*/
[1639 byte] By [Derwin] at [2007-11-20 11:30:27]
# 1 Re: CArchive Exception Handeling
For anyone wondering, the problem arrises because I called the CArchive functions (the << and >> operators) inside the wBody::Serialize(CArchive *ar), so any exceptions those operators threw remained inside the serialize function, and apparently were not accesable once back in the readB function. So I just added a EOF value to the return of serialize, and checked the value of er.
Derwin at 2007-11-10 22:25:13 >