Board index » delphi » Problem with try .. except, exception handler

Problem with try .. except, exception handler

Quote
p...@pobox.com wrote:

> >The exception is NOT being handled by the handler I have written!!!
> >The default system handler puts up the 'usual' error message dialogue
> >and the de{*word*81} stops on the tblClients.Post line in the programme.

>         Hit F9, the de{*word*81} will then continue and pass to the exception block. The
> de{*word*81} stops on exceptions, I WISH we could conditionally turn this
> on/off...

Open Options|Environment dialog and uncheck "Break on exception" on the
Preferences page.

Regards,
Robert Cerny
Email: robert.ce...@neosys.xrs.si

 

Re:Problem with try .. except, exception handler


On 6 Mar 1996 05:06:22 GMT, joy...@kw.igs.net (David G. Joyce) wrote:

Quote
>In article <00009413+00002...@msn.com>, alan_nut...@msn.com says...

>>Hello All,

>>This morning I attempted to add an exception handler to some code
>>that stores a new, or editted, record to a Paradox Table.  Code
>>snippet looks like this:

>>      try
{SNIP}
>>The exception is NOT being handled by the handler I have written!!!  
>>The default system handler puts up the 'usual' error message dialogue
>>and the de{*word*81} stops on the tblClients.Post line in the programme.

>>What am I doing wrong??

>>CHEERIO, Alan.
>Alan

>I just 'upgraded' to the latest version of 16 bit Delphi.  The point is that
>the behaviour you describe is now happening on my system.  Before the upgrade
>the old version would gladly accept the exception handler and continue.  The
>good new it still works fine on the executables running outside the de{*word*81}.

>Maybe someone is aware of a switch to make it like the old Delphi.  When you
>plan for exceptions is annoying to have them always popping up when you have
>enough problems hunting for real bugs.

>Cheers

>DJ

David,

Herewith the solution:  

Under Options | Environment on the 'Preferences' tab of the tabbed
notebook in the Group Box labelled 'Debugging,'  UNCHECK the checkbox
labelled "Break on exception" and this will force the de{*word*81} to
'look' at YOUR exception handler rather than defaulting back to the
system exception handler.

I had several people e-mail me with this 'fix,' for which I am
grateful.  So I onpass it to you and others watching this thread.

Cheerio, Alan. 1110AEST/9 March 1996

Re:Problem with try .. except, exception handler


Quote
alan_nut...@msn.com (Alan NUTLEY) wrote:
>Hello All,
>This morning I attempted to add an exception handler to some code
>that stores a new, or editted, record to a Paradox Table.  Code
>snippet looks like this:
>      try
>              tblClients.Post;
>      except
>         on E: EDatabaseError do
>            begin
>            if MessageDlg('Error: ' + E.Message,
>                        mtError, mbAbortRetryIgnore, 0)= mrRetry then
>               {Do some stuff to recover from exception}                    
>else raise; {ReRaise the exception}

>      end;
>The exception is NOT being handled by the handler I have written!!!  
>The default system handler puts up the 'usual' error message dialogue
>and the de{*word*81} stops on the tblClients.Post line in the programme.
>What am I doing wrong??
>CHEERIO, Alan.

The Exception-Process in Delphi has two ways to execute:

First way  (The IDE is Running):  When an Exception comes, the
De{*word*81} will stop the Programm, and shows the Exception. After
Pressing F9 (or Run|Run) the Programm runs an use the programmed
Exception-Handling.

Second Way (The IDE is NOT running): Whe an exception comes, the
programmed Exception-Handling will be executed)

While the IDE is running, the Exception-Handling can be switched: In
the Options|Environment Notebook, first Page, Section De{*word*81} try the
Halt on exceptions checkbox (I have the German Version of Delphi, hope
i translated the Menu/Checkbox-Names correct).

Hope that helps....

Robert Noeth (RNo...@t-online.de)

Other Threads