lib.App.__run(): Beautify error logging

Without --backtrace, the outmost try-catch block logs exceptions
plainly as their text. If it catches a key error, the exception text
only consists of the key itself, which can be easily mistaken for a
normal program output, so prefix it with a "Failed:".

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-04-13 12:12:40 +02:00
commit 1b2ebab33a

View file

@ -131,9 +131,8 @@ class App: # export
ret = await self._run(self.__args) ret = await self._run(self.__args)
if isinstance(ret, int) and ret >= 0 and ret <= 0xFF: if isinstance(ret, int) and ret >= 0 and ret <= 0xFF:
exit_status = ret exit_status = ret
except Exception as e: except Exception as e:
log(ERR, repr(e) if self.__back_trace else str(e)) log(ERR, 'Failed: {}'.format(repr(e) if self.__back_trace else str(e)))
exit_status = 1 exit_status = 1
if self.__back_trace: if self.__back_trace:
raise raise