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
commit fa60378a7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -89,6 +89,9 @@
- ORC is now the default memory management strategy. Use - ORC is now the default memory management strategy. Use
`--mm:refc` for a transition period. `--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 ## Standard library additions and changes
[//]: # "Changes:" [//]: # "Changes:"

View file

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