Board index » delphi » Raise Exception.Create

Raise Exception.Create

Hi

Raise Exception.Create(This is an Error');
When doing this, Do I also use Exception.Free?

thx

 

Re:Raise Exception.Create


On Sat, 25 Aug 2001 13:10:34 GMT, "N. Johnson"

Quote
<nol...@worldnet.att.net> wrote:
>Hi

>Raise Exception.Create(This is an Error');
>When doing this, Do I also use Exception.Free?

No. The exception is freed automatically when
it is handlded (that is, when it finds an
"except" block somewhere, which it always does
whether you've trapped it or not.)

Quote
>thx

David C. Ullrich

Re:Raise Exception.Create


Only if the exception handler is installed. If not (e.g. in the
initialization or finalization section of a unit), you get a run-time error
216 and the Exception object is only freed, because the application
terminates.

"David C. Ullrich" <ullr...@math.okstate.edu> wrote in message
news:3b87a970.238151@nntp.sprynet.com...

Quote
> On Sat, 25 Aug 2001 13:10:34 GMT, "N. Johnson"
> <nol...@worldnet.att.net> wrote:

> >Hi

> >Raise Exception.Create(This is an Error');
> >When doing this, Do I also use Exception.Free?

> No. The exception is freed automatically when
> it is handlded (that is, when it finds an
> "except" block somewhere, which it always does
> whether you've trapped it or not.)

> >thx

> David C. Ullrich

Re:Raise Exception.Create


On Sat, 25 Aug 2001 15:36:22 +0200, "M.H. Avegaart"

Quote
<avega...@NOSPAMmccomm.nl> wrote:
>Only if the exception handler is installed. If not (e.g. in the
>initialization or finalization section of a unit), you get a run-time error
>216 and the Exception object is only freed, because the application
>terminates.

Right. Of course the word "always" always means "almost always"...

Almost any exception will be handled by the outermost
exception handler installed by Application, even when
there's no try-except visible in one's source code.
There are "exceptions" to this, as you point out. But
I don't think that this matters in regard to the original
question, because I'm not aware of any situation where it
_is_ necessary to Free an exception object.

Quote
>"David C. Ullrich" <ullr...@math.okstate.edu> wrote in message
>news:3b87a970.238151@nntp.sprynet.com...
>> On Sat, 25 Aug 2001 13:10:34 GMT, "N. Johnson"
>> <nol...@worldnet.att.net> wrote:

>> >Hi

>> >Raise Exception.Create(This is an Error');
>> >When doing this, Do I also use Exception.Free?

>> No. The exception is freed automatically when
>> it is handlded (that is, when it finds an
>> "except" block somewhere, which it always does
>> whether you've trapped it or not.)

>> >thx

>> David C. Ullrich

David C. Ullrich

Other Threads