Board index » cppbuilder » try catch pairs problem

try catch pairs problem


2006-02-09 08:25:07 PM
cppbuilder29
I am try to nest two try{}catch{} pairs to capture different levels of
error. The outer pair works fine; however, if there is an error within the
inner try/catch pair execution jumps directly to the last instruction in the
code snippet and bypasses both catch statements. What am I doing wrong ?
<code snippet>
try {
/* A fair amount of normal in-line code here */
try {
MainForm->ControlSession = new ADBSession(&ControlPath, false,
false, servertype, MainForm->currentuser.UserName,
MainForm->currentuser.Password);
}
catch (Exception &e) {
MainForm->currentuser.admin = false;
if (MainForm->ControlSession) delete MainForm->ControlSession;
MainForm->ControlSession = new ADBSession(&ControlPath, true, false,
servertype, "general", "");
}
}
catch (Exception &e) {
MessageDlg("Unable to open\nclient database", mtError, TMsgDlgButtons()
<< mbOK,0);
}
MPasswordDlg->Close();
//---------------------------------------------------------------------------
 
 

Re:try catch pairs problem

John Blackburn wrote:
Quote
I am try to nest two try{}catch{} pairs to capture different levels
of error. The outer pair works fine; however, if there is an error
within the inner try/catch pair execution jumps directly to the last
instruction in the code snippet and bypasses both catch statements.
What am I doing wrong ?
Are you sure you are throwing an exception ;?)
That would explain behaviour, in the snippet you posted.
--
AlisdairM(TeamB)
 

Re:try catch pairs problem

Quote
Are you sure you are throwing an exception ;?)
That would explain behaviour, in the snippet you posted.

--
AlisdairM(TeamB)
My apologies Alisdair, I've just found out what was wrong. There was a try
catch pair within the ADBSession object which was capturing the error
instead - all sorted now.
Thank you for your reply
John
 

{smallsort}

Re:try catch pairs problem

John Blackburn wrote:
Quote
My apologies Alisdair, I've just found out what was wrong. There was
a try catch pair within the ADBSession object which was capturing the
error instead - all sorted now.
No problems. Sometimes simply asking the question helps us find the
answer ourselves ;?)
--
AlisdairM(TeamB)
 

Re:try catch pairs problem

"AlisdairM" < XXXX@XXXXX.COM >wrote in message
Quote
No problems. Sometimes simply asking the question helps us find the
answer ourselves ;?)
Yep...I do it all the time...makes me look pretty silly sometimes too!
- Dennis