[D2005][Firebird]EDatabaseError impossible à intercepter
Bonne année à tous...
Lors de la suppression, si je viole les contrainte d'intégrité de la DB, Delhpi génère un EDabaseError. Je veux le gérer (avec un message) mais rien ne se passe.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| procedure TFrmTypeChambre.ActionSupprimerExecute(Sender: TObject);
begin
try
DM.CDSTypeChambre.Delete;
DM.CDSTypeChambre.ApplyUpdates(0);
except
on EA: EAbort do
begin
DM.CDSTypeChambre.Cancel;
Exit;
end;
on EDB: EDatabaseError do
begin
ShowMessage(ERROR + EDB.Message + NO_DELETE + TYPE_CHAMBRE);
DM.CDSTypeChambre.Cancel;
Exit;
end;
on E: Exception do
begin
ShowMessage(ERROR + E.Message + NO_DELETE + TYPE_CHAMBRE);
DM.CDSTypeChambre.Cancel;
Exit;
end;
end;
end; |
Le EAbort est OK (je le genère dans le BeforeDelete avec un message de confirmation de suppression), mais les autres, je n'y arrive jamais.
Pourquoi? Pourtant quand je supprime j'ai
Citation:
Project raised exception class EDatabaseError with message 'Database server Error : violation of FOREIGN KEY constraint xx on table YY'.
après le 'continue', j'ai
Citation:
Project raised exception class EDatabaseError with message 'Unable to find record. No key specified'
Donc 2 EDatabaseError et mon code ne voit rien 8O
Une idée?