Return error message in output of gorge/staticExec. (#18942)

* Return error message in output of gorge/staticExec.

* Document nimLegacyGorgeErrors in changelog.
This commit is contained in:
Dominik Picheta
2022-10-12 17:52:22 +01:00
committed by GitHub
parent 19ff746916
commit fa60378a7f
2 changed files with 12 additions and 2 deletions

View File

@@ -89,6 +89,9 @@
- ORC is now the default memory management strategy. Use
`--mm:refc` for a transition period.
- The `gorge`/`staticExec` calls will now return a descriptive message in the output
if the execution fails for whatever reason. To get back legacy behaviour use `-d:nimLegacyGorgeErrors`.
## Standard library additions and changes
[//]: # "Changes:"

View File

@@ -49,7 +49,11 @@ proc opGorge*(cmd, input, cache: string, info: TLineInfo; conf: ConfigRef): (str
if result[1] == 0:
writeFile(filename, result[0])
except IOError, OSError:
if not readSuccessful: result = ("", -1)
if not readSuccessful:
when defined(nimLegacyGorgeErrors):
result = ("", -1)
else:
result = ("Error running startProcess: " & getCurrentExceptionMsg(), -1)
else:
try:
var p = startProcess(cmd, workingDir,
@@ -60,4 +64,7 @@ proc opGorge*(cmd, input, cache: string, info: TLineInfo; conf: ConfigRef): (str
result = p.readOutput
p.close()
except IOError, OSError:
result = ("", -1)
when defined(nimLegacyGorgeErrors):
result = ("", -1)
else:
result = ("Error running startProcess: " & getCurrentExceptionMsg(), -1)