PDA

View Full Version : How ot handle errors from EDatabaseError class


Mike
30-Mar-2006, 08:30 AM
How to handle errors from EDatabaseError class?
For example I want to catch
'DataSet: Field 'DataSetField' not found'
and
'Cannot modify a read-only dataset'.
How to do that?

Below is the method this I am using but I think it should be better way.

if (EurekaExceptionRecord.ExceptionObject is EDatabaseError) then
begin
msg := Exception(EurekaExceptionRecord.ExceptionObject).M essage;
if POS('Cannot modify a read-only dataset', msg) <> 0 then
begin
Handled := false;
MyAction....
end;
end;

Mike.

Mike
31-Mar-2006, 10:37 AM
Can I get answer from support?

admin
31-Mar-2006, 11:16 AM
Hi,

Mike wrote:
> Can I get answer from support?

Yes, of course.

I'm sorry but this is a problem, you can only try to cast the EDataBase
exception with the EDBEngineError exception and test its Errors codes.

See the Delphi DBErrors project demo for further details.

On the net you can see this interesting Borland article:
http://bdn.borland.com/article/0,1410,15809,00.html

I hope to have answered to your question! :)

Example:



if (Your_Exception is EDBEngineError) then
if (Your_Exception as EDBEngineError).Errors[0].Errorcode = ...



--
Best regards...

Fabio Dell'Aria.
----------------
http://www.eurekalog.com
Catch every BUG, every time!