If you want to "handle" an exception which was not raised yet, e.g.:
E := Exception.Create('Message');
Application.ShowException(E);
FreeAndNil(E);
You should do it like this:
uses
EExceptionManager; // for ExceptionManager
// ...
ExceptionManager.StandardEurekaError('Message');
This will create pseudo-exception and trigger EurekaLog (to show dialog, save bug report, send, etc.).
Optionally, you may customize EurekaLog for such exceptions (e.g. disable sending, etc.):
uses
EClasses, // for TEurekaModuleOptions
EModules, // for CurrentEurekaLogOptions
EExceptionManager, // for ExceptionManager
ETypes; // for mtErrorMsgCaption
// ...
var
Options: TEurekaModuleOptions;
begin
Options := TEurekaModuleOptions.Create('');
try
Options.Assign(CurrentEurekaLogOptions);
// This is just an example. Alter options as you like
Options.CustomizedTexts[mtErrorMsgCaption] := 'Notification';
ExceptionManager.StandardEurekaError('Message', Options);
finally
FreeAndNil(Options);
end;
end;
However, if you don't want a pseudo-exception class, and need information about real exception object - then you have to specify some additional details, for example:
uses
{$IFDEF EUREKALOG}
ECallStack, // for GetCurrentCallStack and TEurekaBaseStackList
EClasses, // for TEurekaModuleOptions
EExceptionManager, // for ExceptionManager
ETypes, // for mtErrorMsgCaption
{$ENDIF}
// ...
// ...
var
E: Exception;
{$IFDEF EUREKALOG}
EI: TEurekaExceptionInfo;
Stack: TEurekaBaseStackList;
{$ENDIF}
begin
E := Exception.Create('Message');
{$IFDEF EUREKALOG}
EI := ExceptionManager.Info(Pointer(E), nil);
if Assigned(EI) then
begin
// Required, emulates "raising" of the exception
Stack := GetCurrentCallStack;
try
EI.CallStack := Stack;
finally
FreeAndNil(Stack);
end;
// Optional, just an example
EI.Options.CustomizedTexts[mtErrorMsgCaption] := 'Notification';
end;
{$ENDIF}
Application.ShowException(E);
FreeAndNil(E);
end;
Some information related to exception's raising will be missed (such as exception's address, CPU, and assembly info), so you may want to disable these in options.
If you don't mind debugger's notifications - then you may use a shorter alternative:
try
raise Exception.Create('Message');
except
ApplicationHandleException(nil);
end;
See also: