// This will add custom info to bug report
procedure AddMyData(const ACustom: Pointer;
AExceptionInfo: TEurekaExceptionInfo;
ALogBuilder: TBaseLogBuilder;
ADataFields: TStrings;
var ACallNextHandler: Boolean);
// Extract native Delphi exception from exception info
function GetExceptionObject(AExceptionInfo: TEurekaExceptionInfo): Exception;
var
EObj: TObject;
begin
// Exception was thrown by a compatible Delphi version?
if (AExceptionInfo.ExceptionObject <> nil) and
AExceptionInfo.ExceptionNative then
EObj := TObject(AExceptionInfo.ExceptionObject)
else
EObj := nil; // rare
// Exception is SysUtils.Exception?
if EObj is Exception then
Result := Exception(EObj)
else
Result := nil; // very rare
end;
var
E: Exception;
begin
E := GetExceptionObject(AExceptionInfo);
// E is either nil (for non-Delphi exceptions or deleted inner exceptions)
// or E is current Exception
// Add custom info for custom exceptions
if E is EMyException then
ADataFields.Values['Code'] := EMyException(E).Code;
end;
initialization
RegisterEventCustomDataRequest(nil, AddMyData);
end.
|