EUpdateError exception not recognized when raised in TDatasetProvider.OnUpdateError. Why?

Posted by max on Stack Overflow See other posts from Stack Overflow or by max
Published on 2010-05-26T10:07:42Z Indexed on 2010/05/26 10:11 UTC
Read the original article Hit count: 167

Filed under:
|

When I re-throw a EUpdateError exception in the TDatasetProvider.OnUpdateError event, it is not recognized as EUpdateError exception in the catch block. It's only recognized as base Excption.

try
  ...
  //calls the TDatasetPorvider.OnUpdateError event.
  myClientDataSet.ApplyUpdates(0);
  ...
except
 on ex: EUpdateError do
 begin
   //never goes here
   //Evaluate ex.ErrorCode
 end;
 on ex: Exception do
 begin
   //always goes here
   //the expression (ex is EUpdateError) returns false;
 end;
end;

Hiere is the corresponding .OnUpdateError implementaion:

procedure MyDataModule.MyDatasetProviderOnUpdateError(..;E: EUpdateError;...);
beign
  //Here, the expression (E is EUpdateException) returns true;
  raise E;
end;

The exception is re-thrown, but as it seems the EUpdateError is transformed into a plain base Execption.
Does anybody know, why the class type get lost?
I would need that type in order to check the .ErrorCode to know what went wrong and to prepare the proper user message.

© Stack Overflow or respective owner

Related posts about delphi

Related posts about delphi-2009