Unusual try...catch behavior
In my program I have following C++ function:
===========================
extern void
getUserEmailAddress (
std::string &userId,
stringSet &emailAddresses
)
{
int ifail = ITK_ok ;
tag_t userTag = NULLTAG ;
if ((ifail = SA_find_user (userId.c_str (), &userTag)) != ITK_ok)
{
throw (SOTTcEngException (ifail)) ;
}
if (userTag == NULLTAG)
{
throw (SOTTcEngException (SA_finding_user)) ;
}
getUserEmailAddress (userTag, emailAddresses) ;
}
===========================
I expect that if the function "SA_find_user" returns ITK_ok, but userTag is
still NULLTAG, function should throw an exception "SOTTcEngException
(SA_finding_user)".
But what I have seen is that function does throw an exception, but instead
of coming out of the function and entering catch block of the calling
function, execution continues to next statement of "getUserEmailAddress
(userTag, emailAddresses)"...as if that throw statement is an empty statement.
I have seen this behavior wheather I am debugging through visual studio or
executing normally without debugging.
Why program execution continues after throwing an exception? Am I missing
something in the code?
Thanks and Regards