Rohit,

Firstly, unit initialization happens BEFORE your try-except clause.  In
fact, unit initialization happens BEFORE the begin.  So what can you do
about this?

1.  Put all initialization / finalization code that can raise exceptions
into procedures in the unit(s).

2.  Create a new unit.

3.  Use the SysUtils unit and the other units with initialization /
finalization code moved into procedures.

4.  In the initialization section, call all the initialization code.  This
way, if one of them raises an exception, the others will automatically be
skipped.  With this you can also explicitly control the order in which the
units are initialized.

5.  Do the same for finalization, except that you reverse the order in which
you call finalization code.

Hope this helps.

Dennis.


> In the dpr file, I have to had to put in try except block as follows.
>  Otheriwse on certain exceptions in in the initializtion of units it
> is nonsense to carry on running the application.  The user would just
> get so many useless exceptions and possible corruption of database.
>
> The problem is that when an exception does occur, it is still
> followed by two other exceptions deep in the VCL.  Does anyone know
> how I can fix this ?  Is there a better way of doing this ?
>
> The old way of halt and exitproc chain used to work much better.  :-)
>
>
> begin
>   Application.Initialize;
>   try
>     Application.CreateForm(TfrmTimer, frmTimer);
>     Application.Run;
>   except
>     raise;
>   end;
> end.


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to