I have a method with try..catch. the structure is like this:
try
{
commands...
}
catch(...)
{
ERROR(...);
}
if(m_pDoc->m_bS = FALSE ) // Check here if AutoLogout event occurred.
StartCollect();
}
The program doesn't go into the catch section, but it also doesn't go into the if statement later. What can be the problem? Why doesn't the program go to the if statement?
Thanks
Your if statement is almost certainly wrong. You're assigning FALSE to bSilenClose and then checking if it (false) is true, which will cause the body of your if to never execute. In C++ the test for equality is ==. Additionally as @Martin York points out, the trailing ; will be treated as the body of your if. The code below in braces should, in fact, execute every time.
if(m_pDoc->m_bSilenClose = FALSE );
^ ^^^^ This should not be there. (Empty statement after if)
^
^ Assigning FALSE (should be == to test)
Condition always FALSE (thus never executes empty statement.
catch will only be called if an exception occurs. As to why the stuff in the if statement isn't being called, either:
Edit: just noticed this is C++.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With