PDA

View Full Version : raise an exception


Marco
12-Jun-2006, 06:25 AM
Hi,
in my application I need to raise an exception and then terminate the
application, but I want eurekalog to store the exception in the log file.
So I do something like this:
(Windows XP, Delphi 5)

.....
try
raise exception.create('Some message');
finally
Application.Terminate;
Halt(1)
end;
......
With ths code the exception is raised and the application is terminated
but the eureka log file is not written. How can I terminate the
application in the same procedure and have the eureka log file written ?

Thanks.

admin
12-Jun-2006, 07:14 AM
Hi,

Marco wrote:
> Hi,
> in my application I need to raise an exception and then terminate the
> application, but I want eurekalog to store the exception in the log file.
> So I do something like this:
> (Windows XP, Delphi 5)
>
> ....
> try
> raise exception.create('Some message');
> finally
> Application.Terminate;
> Halt(1)
> end;
> .....
> With ths code the exception is raised and the application is terminated
> but the eureka log file is not written. How can I terminate the
> application in the same procedure and have the eureka log file written ?
>
> Thanks.

This happens only because Delphi processed the "Finally" block before process
the exception, so if you kill the application in the "Finally" then Delphi
cannot process the exception! :)

Try with the following code:



uses
ExceptionLog;

....

try
try
raise exception.create('Some message');
except
StandardEurekaNotify(ExceptObject, ExceptAddr);
end;
finally
Application.Terminate;
Halt(1);
end;




--
Best regards...

Fabio Dell'Aria.
----------------
http://www.eurekalog.com
Catch every BUG, every time!

Marco
12-Jun-2006, 08:07 AM
admin <support@eurekalog.com> wrote in news:e6j46e$nqk$1
@plesk.eurekalog.com:

> Fabio Dell'Aria

Thank you very much, it works fine!

Regards,
Marco