I've tried to utilize the System.RaiseList
to get the TRaiseFrame.NextRaise
to no avail - I'm not getting the desired EOleException
... So I found a rather elegant solution which is specific to my case (ADO) and does not rely on the RTL - I'm testing the Errors
object of the TADODataSet.Connection
:
procedure TForm1.DataSetCommit(ds: TADODataSet);
begin
ds.Connection.BeginTrans;
try
try
ds.Post;
except
on E: EDatabaseError do
begin
if Assigned(ds.Connection.Errors) and (ds.Connection.Errors.Count > 0) then
with ds.Connection.Errors.Item[0] do
// if (Number = -2147217864) then ...
ShowMessage(Format('Number:%d; Source:%s; Description:%s; NativeError:%d; SQLState:%s',
[Number, Source, Description, NativeError, SQLState]));
end;
end;
ds.Connection.CommitTrans;
except
ds.Connection.RollbackTrans;
raise;
end;
end;
This will be my solution to the specific problem, but I'm still interested in other ideas on how to trap the previous exception of EOleException
.