Re: QC#6682 - is there a fix?

From: Kurt Barthelmess (kbarthelmess_at_compuserve.com)
Date: 12/22/03


Date: Mon, 22 Dec 2003 17:26:10 GMT


"Pierre le Riche" <pleriche@hotmail.com> wrote:

>If an exception is raised within the OnCreate event of a form and the
>exception is not handled inside the OnCreate itself, but there is a
>try...except...end block in the procedure that creates the form, the
>exception is not trapped properly. I've reported this as QC#6682, and I was
>wondering if anyone knows of a workaround?
>
>At the moment my solution is to do nothing in a form constructor that could
>raise an exception, but this is not always ideal. If anyone knows which
>lines of code to change in the VCL to fix this I would be very grateful.

Give the form which is throwing the exception (not the form which is
trying to create it) a method like so:

  protected
    function HandleCreateException: Boolean; override;

function TForm2.HandleCreateException: Boolean;
begin
  Result := False;
end;

Note that OnCreate is called by your constructor, and the object will
destroyed before your exception code is allowed to execute. Therefore
the not be valid either in the exception handler or later.

Good luck.

Kurt



Relevant Pages

  • Re: Try Finally...
    ... Now we can protect every more or less specialized action ... an error indication (exception or error code) has to be ... an according exception handler can be inserted into the code. ... resources, as they are related to specific actions. ...
    (comp.lang.pascal.delphi.misc)
  • Re: WinForms bug? ThreadException not invoked on Exceptions in system code pre-processing the me
    ... Message Queue and invoking the appropriate handler. ... if an Exception is raised during the PRE-PROCESSING of a Windows ... And because any handling will probably fail if there is no memory, the CLR will terminate the application without attempting to call the ApplicationException or UnhandledException events. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: BackgroungWork taske ended for no appearent reason
    ... To do the same thing with Try/Catch blocks requires wrapping every file access with a Do While ... ... If there was any exception thrown in your DoWork event handler, ... If the operation raises an exception that your code does not handle, ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Frame-based exception handling problem on Server 2008
    ... In this case, the exception ends fatal, usually Cygwin creates a stack ... The Cygwin DLL is a POSIX ... handler is supposed to be *the* exception handler for Cygwin ... It also does not know if the signal handler returns or not. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Frame-based exception handling problem on Server 2008
    ... If I set a breakpoint to our exception ... points to the default handler, our exception handler is called just fine. ... typedef struct _exception_list ...
    (microsoft.public.win32.programmer.kernel)