[Lazarus] Exception hidden ?

Bart bartjunk64 at gmail.com
Fri Dec 25 00:07:46 CET 2009


On 12/24/09, JoshyFun <joshyfun at gmail.com> wrote:

>  Can anybody tell me why this code does not raise an exception and
>  silently kills the program ?

It actually does raise an exception.

bart at simenon:~/LazarusProjecten> ./leeg
[FORMS.PP] ExceptionOccurred
  Sender=EFOpenError
  Exception=Unable to open file "NonExistsFilename"
  Stack trace:
  $0808EAA8
  $080877F1  UFRMMAIN_init,  line 27 of ufrmmain.pas
  $0806D2B4
TApplication.HandleException Unable to open file "NonExistsFilename"
  Stack trace:
  $0808EAA8
  $080877F1  UFRMMAIN_init,  line 27 of ufrmmain.pas
  $0806D2B4
exception at 0808EAA8:
Unable to open file "NonExistsFilename".


Just run the program from commandline (in Windows uncheck Win32 GUI
application in Project -> Compiler Options -> Linking, or put
{$APPTYPE CONSOLE} at top of your .lpr file)

The unhandled exception is handled by the deafult exception handler,
which (I guess) at that point in time, is not the exception handler
that you expect (the fancy one showing the message with option
Continue/Terminate).

I think it all has to do with at what time which exceptionhandler is
initialised.

Bart




More information about the Lazarus mailing list