diff --git a/src/python/jw/pkg/lib/App.py b/src/python/jw/pkg/lib/App.py index 028dbd38..1fb2b754 100644 --- a/src/python/jw/pkg/lib/App.py +++ b/src/python/jw/pkg/lib/App.py @@ -116,10 +116,7 @@ class App: # export try: ret = await self._run(self.__args) except Exception as e: - if hasattr(e, 'message'): - log(ERR, e.message) - else: - log(ERR, f'Exception: {type(e)}: {e}') + log(ERR, repr(e) if self.__back_trace else str(e)) exit_status = 1 if self.__back_trace: raise diff --git a/src/python/jw/pkg/lib/Cmd.py b/src/python/jw/pkg/lib/Cmd.py index 646e3c85..a5cdf489 100644 --- a/src/python/jw/pkg/lib/Cmd.py +++ b/src/python/jw/pkg/lib/Cmd.py @@ -89,7 +89,7 @@ class Cmd(abc.ABC): # export self.__children.append(cmd) assert len(self.__children) == len(self.__child_classes) except Exception as e: - cmds.dump(ERR, f"Failed to add subcommands ({e})") + cmds.dump(ERR, f"Failed to add subcommands ({str(e)})") raise return raise Exception(f'Tried to add sub-commands of unknown type {type(cmds)}') diff --git a/src/python/jw/pkg/lib/util.py b/src/python/jw/pkg/lib/util.py index 8a6c2cc2..06722b37 100644 --- a/src/python/jw/pkg/lib/util.py +++ b/src/python/jw/pkg/lib/util.py @@ -20,7 +20,7 @@ def pretty_cmd(cmd: list[str], wd=None): if token.find(' ') != -1: token = '"' + token + '"' tokens.append(token) - ret = ' '.join(tokens) + ret = '>' + ' '.join(tokens) + '<' if wd is not None: ret += f' in {wd}' return ret @@ -57,10 +57,7 @@ async def run_cmd( def __check_exit_code(code): if code != 0 and (throw or verbose): - msg = ( - time.strftime("%Y-%m-%d %H:%M") - + f': Command returned error {code}: "{pretty_cmd(args, wd)}"' - ) + msg = f'Command returned error {code}: {pretty_cmd(args, wd)}' if verbose: __log(ERR, msg) if throw: @@ -184,7 +181,7 @@ async def run_curl(args: list[str], parse_json: bool=True, wd=None, throw=None, size = len(ret) except: pass - print(f'Failed to parse {size} bytes output of command >{pretty_cmd(cmd, wd)}< ({e})', file=sys.stderr) + print(f'Failed to parse {size} bytes output of command >{pretty_cmd(cmd, wd)}< ({str(e)})', file=sys.stderr) raise return ret