Board index » delphi » try..except..huh?

try..except..huh?

When an key violation occurs in the following AppendRecord(), the
standard DP4 key violation exception handling occurs BEFORE my own
exception key violation code executes. What am I doing wrong?

-Ted

try
    AppendRecord([ theBarcode.fLeft, theBarcode.fRight,])
except
    on e: EDBEngineError
        do for theIdx := 0 to e.ErrorCount-1
            do case e.Errors[theIdx].ErrorCode of
                eKeyViol: ShowMessage('My key violation');
                else ShowMessage('My unspecified EDBEngineError');
            end;
end;

 

Re:try..except..huh?


Solution: The exception was seemingly being handled by Delphi before my
own exceptoin handler because of a IDE de{*word*81} feature called "break on
exception" which is set from the IDE menu at:

tools | De{*word*81} Options | Language Exceptions | Stop on Delphi
Exception

I did not see any references in the various online docs advising
developers to turn off this feature to get exceptions to work.

-Ted

Quote
Ted Michon wrote:
> When an key violation occurs in the following AppendRecord(), the
> standard DP4 key violation exception handling occurs BEFORE my own
> exception key violation code executes. What am I doing wrong?

> -Ted

> try
>     AppendRecord([ theBarcode.fLeft, theBarcode.fRight,])
> except
>     on e: EDBEngineError
>         do for theIdx := 0 to e.ErrorCount-1
>             do case e.Errors[theIdx].ErrorCode of
>                 eKeyViol: ShowMessage('My key violation');
>                 else ShowMessage('My unspecified EDBEngineError');
>             end;
> end;

Re:try..except..huh?


Actually, I think you are better off leaving it on.
Otherwise you may have problems finding
exceptions you haven't planned on.
Just realize that you'll see the break even
if you have an exception handler in your code.

Quote
Ted Michon <tedmic...@home.com> wrote in message

news:378E771B.D53E8B1E@home.com...
Quote
> Solution: The exception was seemingly being handled by Delphi before my
> own exceptoin handler because of a IDE de{*word*81} feature called "break on
> exception" which is set from the IDE menu at:

> tools | De{*word*81} Options | Language Exceptions | Stop on Delphi
> Exception

> I did not see any references in the various online docs advising
> developers to turn off this feature to get exceptions to work.

> -Ted

> Ted Michon wrote:

> > When an key violation occurs in the following AppendRecord(), the
> > standard DP4 key violation exception handling occurs BEFORE my own
> > exception key violation code executes. What am I doing wrong?

> > -Ted

> > try
> >     AppendRecord([ theBarcode.fLeft, theBarcode.fRight,])
> > except
> >     on e: EDBEngineError
> >         do for theIdx := 0 to e.ErrorCount-1
> >             do case e.Errors[theIdx].ErrorCode of
> >                 eKeyViol: ShowMessage('My key violation');
> >                 else ShowMessage('My unspecified EDBEngineError');
> >             end;
> > end;

Re:try..except..huh?


In article <378E771B.D53E8...@home.com>, Ted Michon stated:
Quote
> I did not see any references in the various online docs advising
> developers to turn off this feature to get exceptions to work.

Ted,

Exceptions are working whether or not you have break on exceptions
checked. The only difference is that Delphi will show the exception in
the IDE. This can come in very handy when you are getting unwanted
exceptions and it breaks on the line that is causing it. You can
suppress specific exceptions by adding them to the "Exception types to
ignore" list. I generally test with Break on Exceptions enabled.

--
Regards
Ralph (TeamB)
--

Other Threads