From 30ed0965e9be8430d04ccc1ea11a5d2c1e23f41f Mon Sep 17 00:00:00 2001 From: Yufan You Date: Sun, 30 Jun 2024 12:01:26 +0800 Subject: [PATCH] fix: error handling for displaying pacman errors --- pacwatch.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pacwatch.py b/pacwatch.py index 51bd920..c48cf2b 100755 --- a/pacwatch.py +++ b/pacwatch.py @@ -107,8 +107,14 @@ def pacman(args: str, display: bool, noConfirm: bool = True, check: bool = True) except subprocess.CalledProcessError as e: print('\n--- pacman error ---\n') print('exit code: {}'.format(e.returncode)) - print('stderr: {}'.format(e.stderr.decode())) - print('stdout: {}'.format(e.output.decode())) + try: + print('stderr: {}'.format(e.stderr.decode())) + except: + pass + try: + print('stdout: {}'.format(e.output.decode())) + except: + pass print('\n--- pacman error ---\n') raise e