Subject IBO Exception not caught??
Author G. Allen Casteran
I have a D6 proc that calls an IBO storedProc. If the SP fails I want to
catch the exception.

When I run this proc the exception can not be caught as an EIBO_ISCError.
Only the generic exception handler gets run. I can trap the exception as
generic exception in the "on e: Exception do" statement. but when I have
"on E: EIBO_ISCError do" the exception does not get cuaght.

In my first handler below I try to see ig the E IS an EIBO_ISCError and in
the debugger that shows as TRUE when I hold the cursor over it, but the
execution treats that statement as if it is false.

Originally I just had the code after the except line, but I added the on E:
Exception code to see what was happening in that case.

Anyone have a good reason for an exception not getting caught??

Thanks,
Allen.

Here is the proc:

procedure TBudgetTemplatesDataModule.CopySelectedTemplate(
const aNewAbbrevName: String;
const aNewTableName: String);
var
SP : TIB_StoredProc;
ConstName : string;
begin
if (aNewTableName = '') or (aNewAbbrevName = '') then
Raise Exception.Create('Abbrev and Template Name must be specified for
copy.');
SP := TIB_StoredProc.Create(Self);
try
try
SP.DatabaseName := MainDatabaseName;
SP.StoredProcName := 'SP_COPY_BUDGET_TEMPLATE';
SP.Prepare;
SP.ParamByName('aSourceTemplateKey').AsInt64 := SelectionDataCurrentKey;
SP.ParamByName('aNewAbbrev').AsString := aNewAbbrevName;
SP.ParamByName('aNewTableName').AsString := aNewTableName;
SP.ExecProc;
except
on E: EIBO_ISCError do // This block never gets run.
begin
ConstName := GetContraintNameFromDBMsg(E.Message);
if (ConstName = 'UC_BUDGTEMPL_ABBREVNAME') then
E.Message := 'Abbrev Name must be unique within each lender.'
else if (ConstName = 'IC_BUDGTEMPL_ABBREV') then
E.Message := 'Abbrev Name must be assigned.'
else if (ConstName = 'FK_BUDGTEMPLS_LENDERS') then
E.Message := 'A valid lender must be assigned to this template.';
Raise EIconDBException.Create(Str_FailCopyBudgetTemplate + E.Message);
end;
on E: Exception do // exception handling ALWAYS hits here.
begin
if (E IS EIBO_ISCError) then // this is TRUE when inspected in
the debugger
begin // Code in this block
never runs
with EIBO_ISCError(E) do // even though E *IS* a EIBO_ISCError
begin
ConstName := GetContraintNameFromDBMsg(Message);
if (ConstName = 'UC_BUDGTEMPL_ABBREVNAME') then
Message := 'Abbrev Name must be unique within each lender.'
else if (ConstName = 'IC_BUDGTEMPL_ABBREV') then
Message := 'Abbrev Name must be assigned.'
else if (ConstName = 'FK_BUDGTEMPLS_LENDERS') then
Message := 'A valid lender must be assigned to this template.';
Raise EIconDBException.Create(Str_FailCopyBudgetTemplate +
Message);
end;
end
else
Raise EIconDBException.Create(Str_FailCopyBudgetTemplate +
E.Message); // t
end;
end;
finally
SP.Free;
end;
end;