spiegel-keyman/common/windows/delphi/ext/sentry/Sentry.Client.Vcl.pas
2022-06-06 15:13:53 +10: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.