Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Raise Exception from Nexted Unit does not work.

Status
Not open for further replies.

6volt

Programmer
Jun 4, 2003
74
0
0
US
I have code where in the main UNIT, I test for various problems and if I find one that I expect, I CREATE my own EXCEPTION and RAISE it:

type
EFatalError = class (Exception);
.....

RAISE eFatalError.Create ('helpful message');


This works great and I get a helpful message explaining what went wrong.

However, I have a UNIT full of common routines which appears in the USE statement of this main UNIT.

Common PROCEDURES and FUNCTIONS in this USEd unit also use the same exception raising coding that the main unit used.

The problem is that my attempt to raise exceptions from the common unit do not appear to work - I never get the message.

I really don't know what to do at this point. I tried to see if constructs like FormMain.RAISE or RAISE FormMain.eFatalError.Create and they are all bogus. I get the suspicion that the exception is not raised up the tree of calling units.

I am dead in the water at this point and would greatly appreciate any help or suggestions.

Thanks so much in advance,
Regards,
Tom
 
Errata: I meant "Nested Unit" in title (argh!)

AND....

HOW do I edit a post???

Thanks
Tom
 
...I'm looking at Compiler options...
 
Some insight gained:

The main unit has TRY EXCEPT that encapsulates the entire program.

The second unit has no TRY's whatsoever.

So I put a TRY EXCEPT encapsulating the entire code in the second unit Procedure what should have been Raising the error and finally got the FATAL Error Message I was looking for.

Only problem was that now, execution was NOT halted (!) ...it just kept on going until something else blew.

Thanks
Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top