shyampaliyath
asked on
Exception
hai
the problem is that i want to capture an exception message when it occurs and store it in a log file. Suppose if an EDBEngineError occurs i want to capture the exception as well as the related system thrown message and store it in a log file.
thank u in advance...
the problem is that i want to capture an exception message when it occurs and store it in a log file. Suppose if an EDBEngineError occurs i want to capture the exception as well as the related system thrown message and store it in a log file.
thank u in advance...
Suppose that you have function called AddLog that add string line to Log file:
try
// put your database manipulation code here:
except
on e: exception do
AddLog(E.Message);
end;
try
// put your database manipulation code here:
except
on e: exception do
AddLog(E.Message);
end;
Delphi 5 introduced a simpler way of achieving this. Use the TApplicationEvents component on the Additional tab:
In the OnException event, put the passed exception's message in your log file, then call Raise to show the exception to the user.
If you are using a version of Delphi less than D5, then you'll have to write your own procedure then assign it to the Application's OnException event in your main form's OnCreate, e.g.
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnException := MyExceptionHandlingProcedu re;
end;
J.
In the OnException event, put the passed exception's message in your log file, then call Raise to show the exception to the user.
If you are using a version of Delphi less than D5, then you'll have to write your own procedure then assign it to the Application's OnException event in your main form's OnCreate, e.g.
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnException := MyExceptionHandlingProcedu
end;
J.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You might also want to look at my exception handling package:
http://help.madshi.net/Data/madExcept.htm
Regards, Madshi.
http://help.madshi.net/Data/madExcept.htm
Regards, Madshi.
Glad to help!
Please show your support by entering this sites:
www.victory.hpg.com.br
www.enge.cjb.net
www.boatoda.hpg.com.br
VSF
victory@e-net.com.br
Please show your support by entering this sites:
www.victory.hpg.com.br
www.enge.cjb.net
www.boatoda.hpg.com.br
VSF
victory@e-net.com.br
JclDebug is what you need even that only catching and logging the exceptions is almost too easy for the unit :-)