Board index » off-topic » Exception handling problem in Cached Updates
|
nomail
Delphi Developer |
Exception handling problem in Cached Updates2007-12-25 08:08:11 PM off-topic8 It's a delphi 4 question. Might be a question for delphi RTL group, but I am posting it here since it's related to BDE operations in case that is the relevant issue. In the following code I have problem with exceptions that are generated during ApplyUpdates to the database. In the try except block I want to catch the exception, do some fixup work and then re-raise the exception to higher level, but unless raise immediately follows except my exception is lost and raise has no effect. Does anybody knows what is the problem since code looks ok to me and the delphi help examples are showing that one can make some work in the except block and then just raise the same exception again. If I remove the for loop code between except and raise then raise is working ok. procedure TdmBaseData.ApplyUpdates(const DataSets: array of TDBDataSet); var i, n: integer; TmpDS: array of TDBDataSet; TmpData: array of TDataRecord; HasUpdates: boolean; begin n := 0; HasUpdates := false; for i := Low(DataSets) to High(DataSets) do if DataSets[i].Active then begin Inc(n); SetLength(TmpDS, n); SetLength(TmpData, n); TmpDS[n-1] := DataSets[i]; TmpData[n-1].Posted := false; if (DataSets[i].State in dsEditModes) or DataSets[i].UpdatesPending then HasUpdates := true; if (DataSets[i].State in dsEditModes) then begin DataSets[i].Post; TmpData[n-1].Posted := true; end; end; if HasUpdates then begin try TmpDS[0].Database.ApplyUpdates(TmpDS); except for i := 0 to n-1 do begin if TmpData[i].Posted and not (TmpDS[i].State in dsEditModes) then TmpDS[i].Edit; end; -- Following raise does nothing, -- and code continues after the except block raise; end; ... end; end; tomi. |
