Link to home
Start Free TrialLog in
Avatar of ray_leach
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?
Avatar of florisb
florisb

in formcreate:
application.OnException := myError;
end;

procedure TForm1.myError(Sender: TOBject; Error: Exception);
begin
screen.cursor := crDefault;
ShowMessage('An error....;-(');
end;
ASKER CERTIFIED SOLUTION
Avatar of Epsylon
Epsylon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ray_leach

ASKER

Adjusted points from 100 to 120
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(Sender: 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 ...

Run it outside Delphi! Delphi always raises the exceptions, no matter what you do.
Thanks guys!