From ccb85aa08655e565cd1b53c5b9d3c9e430d9f6c7 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Tue, 18 Oct 2016 06:41:29 +0200 Subject: [PATCH] dastworx, add error detection from CE side --- src/ce_common.pas | 16 ++++++++++++++++ src/ce_dastworx.pas | 5 +++++ src/ce_symlist.pas | 2 ++ 3 files changed, 23 insertions(+) diff --git a/src/ce_common.pas b/src/ce_common.pas index f1781798..e141fd6f 100644 --- a/src/ce_common.pas +++ b/src/ce_common.pas @@ -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. diff --git a/src/ce_dastworx.pas b/src/ce_dastworx.pas index b3adfa89..8227fe7e 100644 --- a/src/ce_dastworx.pas +++ b/src/ce_dastworx.pas @@ -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; diff --git a/src/ce_symlist.pas b/src/ce_symlist.pas index a4cef914..719b6f76 100644 --- a/src/ce_symlist.pas +++ b/src/ce_symlist.pas @@ -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;