spiegel-keyman/windows/src/ext/sentry/Sentry.Client.Vcl.pas
Marc Durdin 90f4a5109f feat(windows): report process start to sentry
Also handles -sentry-client-test-exception command line parameter
for console apps and tidies up Sentry instantiation.
2020-03-30 12:21:47 +11:00

49 lines
1.1 KiB
ObjectPascal

unit Sentry.Client.Vcl;
interface
uses
System.SysUtils,
Sentry.Client;
type
TSentryClientVcl = class(TSentryClient)
private
procedure HandleApplicationException(Sender: TObject; E: Exception);
public
constructor Create(AOptions: TSentryClientOptions; const ALogger: string; AFlags: TSentryClientFlags); override;
destructor Destroy; override;
end;
implementation
uses
Vcl.Forms;
{ TSentryClientVcl }
constructor TSentryClientVcl.Create(AOptions: TSentryClientOptions;
const ALogger: string; AFlags: TSentryClientFlags);
begin
inherited Create(AOptions, ALogger, AFlags);
if scfCaptureExceptions in AFlags then
begin
Application.OnException := HandleApplicationException;
end;
end;
destructor TSentryClientVcl.Destroy;
begin
inherited Destroy;
if (TMethod(Application.OnException).Code = @TSentryClientVcl.HandleApplicationException)
and (TMethod(Application.OnException).Data = Self) then
Application.OnException := nil;
end;
procedure TSentryClientVcl.HandleApplicationException(Sender: TObject; E: Exception);
begin
SentryHandleException(E);
end;
end.