From 714e9af99a583484f7640049604be64007321124 Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Fri, 3 Mar 2023 02:38:45 +0000 Subject: [PATCH] Don't print traceback of subprocess errors on download failures Since we now have pretty logs for them, the exception (which would be a CalledProcessError) would be generally pointless. However, the return code may be useful so that is kept. --- devine/commands/dl.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/devine/commands/dl.py b/devine/commands/dl.py index 9ede89e..4d557ec 100644 --- a/devine/commands/dl.py +++ b/devine/commands/dl.py @@ -6,6 +6,7 @@ import math import random import re import shutil +import subprocess import sys import time from concurrent import futures @@ -483,14 +484,19 @@ class dl: (0, 5, 1, 5) )) return - except Exception: # noqa - console.print_exception() + except Exception as e: # noqa + error_messages = [ + ":x: Download Failed...", + " One of the download workers had an error!", + " See the error trace above for more information." + ] + if isinstance(e, subprocess.CalledProcessError): + # ignore process exceptions as proper error logs are already shown + error_messages.append(f" Process exit code: {e.returncode}") + else: + console.print_exception() console.print(Padding( - Group( - ":x: Download Failed...", - " One of the download workers had an error!", - " See the error trace above for more information." - ), + Group(*error_messages), (1, 5) )) return