chore(windows): move reportExceptions check in exception handler to caller

This commit is contained in:
Marc Durdin 2023-12-11 20:44:53 +07:00
parent 67379f4603
commit 3d5506ef3e
2 changed files with 26 additions and 31 deletions

View file

@ -135,6 +135,7 @@ var
{$IF NOT DEFINED(CONSOLE)}
ApplicationTitle, CommandLine: string;
tsysinfopath, enginepath: string;
keyman_root: string;
{$ENDIF}
begin
if EventType = scetException then
@ -176,23 +177,37 @@ begin
ApplicationTitle := AppID;
{$ENDIF}
CommandLine := Format('-c "%s" "%s" "%s" "%s" "%s" "%s"', [
CommandLine := Format('-c "%s" "%s" "%s" "%s" "%s" "%s" %s', [
IfThen(EventID = '', '_', EventID),
IfThen(ApplicationTitle = '', ChangeFileExt(ExtractFileName(ParamStr(0)),''), ApplicationTitle),
AppID,
ProjectName,
EventClassName,
StringReplace(Message, '"', '""', [rfReplaceAll])
StringReplace(Message, '"', '""', [rfReplaceAll]),
IfThen(FClient.ReportExceptions, 'report', 'no-report')
]);
try
tsysinfopath := TKeymanPaths.KeymanEngineInstallPath('tsysinfo.exe');
enginepath := TKeymanPaths.KeymanEngineInstallPath('');
except
on E:EKeymanPath do
begin
tsysinfopath := '';
enginepath := '';
if TKeymanPaths.RunningFromSource(keyman_root) then
begin
enginepath := keyman_root + 'windows\bin\engine';
tsysinfopath := enginepath + '\tsysinfo.exe';
end
else if FileExists(ExtractFilePath(ParamStr(0)) + 'tsysinfo\tsysinfo.exe') then
begin
enginepath := ExtractFilePath(ParamStr(0)) + 'tsysinfo';
tsysinfopath := enginepath + '\tsysinfo.exe';
end
else
begin
try
tsysinfopath := TKeymanPaths.KeymanEngineInstallPath('tsysinfo.exe');
enginepath := TKeymanPaths.KeymanEngineInstallPath('');
except
on E:EKeymanPath do
begin
tsysinfopath := '';
enginepath := '';
end;
end;
end;
if (tsysinfopath = '') or not TUtilExecute.Shell(0, tsysinfopath, enginepath, CommandLine) then
@ -314,7 +329,6 @@ end;
constructor TKeymanSentryClient.Create(SentryClientClass: TSentryClientClass; AProject: TKeymanSentryClientProject; const ALogger: string; AFlags: TKeymanSentryClientFlags);
var
reg: TRegistry;
o: TSentryClientOptions;
f: TSentryClientFlags;
path: string;

View file

@ -92,11 +92,9 @@ function RunCrashReportHandler: Boolean;
implementation
uses
System.Win.Registry,
Vcl.Clipbrd,
Keyman.System.KeymanSentryClient,
RegistryKeys,
Upload_Settings,
utilexecute;
@ -124,8 +122,6 @@ function RunCrashReportHandler: Boolean;
var
frm: TfrmExceptionHandler;
crashID, applicationName, applicationID, projectName, eventClassName, eventMessage: string;
reg: TRegistry;
RegKey: string;
reportExceptions: Boolean;
begin
if ParamStr(1) <> '-c' then
@ -137,6 +133,7 @@ begin
projectName := ParamStr(5);
eventClassName := ParamStr(6);
eventMessage := ParamStr(7);
reportExceptions := ParamStr(8) = 'report';
Application.CreateForm(TfrmExceptionHandler, frm);
Application.Title := applicationName;
@ -147,22 +144,6 @@ begin
frm.EventClassName := eventClassName;
frm.EventMessage := eventMessage;
// Load the registry settings for privacy settings
if projectName = SENTRY_PROJECT_NAME_DESKTOP
then RegKey := SRegKey_KeymanEngine_CU
else RegKey := SRegKey_IDEOptions_CU;
reg := TRegistry.Create;
try
reportExceptions :=
not reg.OpenKeyReadOnly(RegKey) or
not reg.ValueExists(SRegValue_AutomaticallyReportErrors) or
reg.ReadBool(SRegValue_AutomaticallyReportErrors);
finally
reg.Free;
end;
frm.lblText2.Visible := reportExceptions;
frm.lblNoPersonal.Visible := reportExceptions;
//? frm.lblNotReported.Visible := not reportExceptions;