Hi
I understood that if MadExcept is enabled the AppException will not fire
There seem to be some exceptions
Database errors (I am using NativeDB to access a Sybase database)
ENativeDatasetErrors are not trapped by MadExcept, picked up by the original exception handler.
This behaviour is fine by me but I though you aught to know.
Regards Mike
Code pasted below in case you are interested
The DBError dialog get displayed, nothing from MadExcept
procedure TMain.AppException(Sender: TObject; E: Exception);
var Go, Ok, IE: Boolean;
X, Y: string;
Z: TFieldType;
begin
if not AsaSession1.Connected then begin
Application.ShowException(E);
Application.Terminate;
end else begin
Ok := True;
Go := False;
IE := False;
if (Sender is TDBEdit) or (Sender is TDBXGrid) then begin
if (Sender is TDBEdit) then begin
with Sender as TDBEdit do begin
X := Text;
Y := Field.DisplayName;
Z := Field.DataType;
end;
end else begin
with Sender as TDBXGrid do begin
X := InPlaceEditor.Text;
Y := SelectedField.DisplayName;
Z := SelectedField.DataType;
end;
end;
if (Z = ftFloat) or (Z = ftCurrency) then begin
if Format(SInvalidFloatValue, [X, Y]) = E.Message then begin
E.Message := Format('[ %s ] is not a valid floating point value.', [X]);
IE := True;
if DoCancel then begin
NotValid := True;
Go := True;
end;
end;
end;
if (Z = ftSmallInt) or (Z = ftInteger) or (Z = ftWord) then begin
if Format(SInvalidIntegerValue, [X, Y]) = E.Message then begin
E.Message := Format('[ %s ] is not a valid integer value.', [X]);
IE := True;
if DoCancel then begin
NotValid := True;
Go := True;
end;
end;
end;
if Z = ftDate then begin
if Format(SInvalidDate, [X, Y]) = E.Message then begin
E.Message := Format('[ %s ] is not a valid date.', [X]);
IE := True;
if DoCancel then begin
NotValid := True;
Go := True;
end;
end;
end;
end;
if (Sender is TDBCtrlGrid) and (E is EInvalidOperation) then begin
if E.Message = 'Cannot focus a disabled or invisible window' then begin
Go := True;
end;
end;
if not Go then begin
if Sender is TControl then begin
if TControl(Sender).Owner = nil then begin
E.Message := TControl(Sender).Name + #13#10#13#10 + E.Message;
end else begin
E.Message := TControl(Sender).Owner.Name + '.' +
TControl(Sender).Name + #13#10#13#10 + E.Message;
end;
end;
if Ok and (E is ENativeDatasetError) then begin
DbError.Memo1.Text := 'Database Error - Processing Aborted';
DbError.Memo2.Text := E.Message;
DbError.ShowModal;
end else begin
Application.ShowException(E);
end;
if not IE then begin
DataMod.LogE.ParamByName('xtype').Value := E.ClassName;
DataMod.LogE.ParamByName('xmess').Value := E.Message;
DataMod.LogE.ParamByName('xwho').Value := UserSeq;
try
DataMod.LogE.ExecProc;
except
end;
end;
end;
end;
end;
AppException still working - for some errors
How is AppException connected to receive exceptions? Is it connected through Application.OnException?
Maybe NativeDB directly checks and calls Application.OnException internally. What you could do to work around it is to change your code like this:
Normally this is not necessary, because madExcept hooks into Application.HandleException and Application.ShowException. However, if NativeDB directly calls Application.OnException, then this is not catched by madExcept.
Maybe NativeDB directly checks and calls Application.OnException internally. What you could do to work around it is to change your code like this:
Code: Select all
procedure TMain.AppException(Sender: TObject; E: Exception);
begin
madExcept.HandleException(etNormal, E);
end;
AppException
How is AppException connected to receive exceptions? Is it connected through Application.OnException?
Yes it is.
I tried your work arround and it did not do anything
Thanks
Michael
Yes it is.
I tried your work arround and it did not do anything
Thanks
Michael