jw.pkg.lib.util.run_curl(): Beautify logging

Make some incomprensible parser error messages if run_curl() returns
nothing slightly less incomprehensible.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-02-27 15:45:08 +01:00
commit afc77ab61d

View file

@ -230,12 +230,13 @@ async def run_curl(args: list[str], parse_json: bool=True, wd=None, throw=None,
try:
return json.loads(ret)
except Exception as e:
size = 'None'
size = 'unknown number of'
try:
size = len(ret)
except:
pass
print(f'Failed to parse {size} bytes output of command >{pretty_cmd(cmd, wd)}< ({str(e)})', file=sys.stderr)
print(f'Failed to parse {size} bytes output of command '
+ f'>{pretty_cmd(cmd, wd)}< ({str(e)}): "{ret}"', file=sys.stderr)
raise
return ret