dastworx, add error detection from CE side

This commit is contained in:
Basile Burg 2016-10-18 06:41:29 +02:00
parent 6966404525
commit ccb85aa086
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
3 changed files with 23 additions and 0 deletions

View File

@ -292,6 +292,8 @@ type
*)
function openUrl(const value: string): boolean;
procedure tryRaiseFromStdErr(proc: TProcess);
var
// supplementatl directories to find background tools
additionalPath: string;
@ -1310,6 +1312,20 @@ begin
{$ENDIF}
end;
procedure tryRaiseFromStdErr(proc: TProcess);
begin
if (proc.ExitStatus <> 0) and (poUsePipes in proc.Options) then
with TStringList.Create do
try
LoadFromStream(proc.Stderr);
Insert(0, format('tool crashed with code: %d (%s)',
[proc.ExitStatus, shortenPath(proc.Executable)]));
raise Exception.Create(Text);
finally
free;
end;
end;
initialization
registerClasses([TCEPersistentShortcut]);
end.

View File

@ -34,6 +34,7 @@ end;
procedure getModuleImports(source, imports: TStrings);
var
err: TStringList;
str: string;
prc: TProcess;
begin
@ -51,6 +52,8 @@ begin
prc.Input.Write(str[1], str.length);
prc.CloseInput;
processOutputToStrings(prc, imports);
// TODO-cmaintenance: remove this from version 3 gold
tryRaiseFromStdErr(prc);
while prc.Running do ;
finally
prc.free;
@ -75,6 +78,8 @@ begin
prc.Execute;
prc.CloseInput;
processOutputToStrings(prc, results);
// TODO-cmaintenance: remove this from version 3 gold
tryRaiseFromStdErr(prc);
while prc.Running do ;
finally
prc.free;

View File

@ -782,6 +782,8 @@ begin
clearTree;
updateVisibleCat;
if fDoc.isNil then exit;
// TODO-cmaintenance: remove this from version 3 gold
tryRaiseFromStdErr(fToolProc);
//
fToolProc.OnTerminate := nil;
fToolProc.OnReadData := nil;