ray_leach
asked on
Trapping EOLEException exceptions
How to I trap EOLEException exceptions that occur during OLEDB operations, specifically ADO database methods?
I've tried the standard exception code :
try
ado.database.commands.here ;
except
on EOLEException do AppException;
end;
This doesn't trap the EOLEException, or at least suppress it.
What I'm loooking for is a way to suppress the program displaying the EOLEException message.
Any ideas?
I've tried the standard exception code :
try
ado.database.commands.here
except
on EOLEException do AppException;
end;
This doesn't trap the EOLEException, or at least suppress it.
What I'm loooking for is a way to suppress the program displaying the EOLEException message.
Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Adjusted points from 100 to 120
ASKER
Thanks guys, but I've already got that and what happens is the exception is raised before my handler is called.
Is there something that I'm missing.
Below is my code:
type
TfrmSetup = class(TForm)
....
....
public
{ Public declarations }
procedure AppException(Sender: TObject; E: Exception);
end;
....
....
procedure TfrmSetup.FormCreate(Sende r: TObject);
var
Reg : TRegistry;
begin
Application.OnException := frmSetup.AppException;
....
....
end;
....
....
try
BuildAccessDB(Self);
except
on E : EOleException do AppException(Self,E);
end;
....
This handler is not called until after the exception is displayed, which is not what the help pages say. The help says that the ShowException method will be called unless an OnException event handler is declared ...
Is there something that I'm missing.
Below is my code:
type
TfrmSetup = class(TForm)
....
....
public
{ Public declarations }
procedure AppException(Sender: TObject; E: Exception);
end;
....
....
procedure TfrmSetup.FormCreate(Sende
var
Reg : TRegistry;
begin
Application.OnException := frmSetup.AppException;
....
....
end;
....
....
try
BuildAccessDB(Self);
except
on E : EOleException do AppException(Self,E);
end;
....
This handler is not called until after the exception is displayed, which is not what the help pages say. The help says that the ShowException method will be called unless an OnException event handler is declared ...
Run it outside Delphi! Delphi always raises the exceptions, no matter what you do.
ASKER
Thanks guys!
application.OnException := myError;
end;
procedure TForm1.myError(Sender: TOBject; Error: Exception);
begin
screen.cursor := crDefault;
ShowMessage('An error....;-(');
end;