From f23100077e1f8f0fe55678fe2975174424ae0f9c Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Wed, 24 Apr 2024 05:28:10 +0100 Subject: [PATCH] refactor(dl): Improve readability of download worker errors Now it will no longer print the full traceback for errors caused by a missing binary file. Other errors still include it and now explicitly label them as unexpected. CalledProcessError handling is now merged with all non-environment related errors and explicitly mentions that a binary call failed. --- devine/commands/dl.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/devine/commands/dl.py b/devine/commands/dl.py index 054c9d9..2891f05 100644 --- a/devine/commands/dl.py +++ b/devine/commands/dl.py @@ -547,14 +547,17 @@ class dl: except Exception as e: # noqa error_messages = [ ":x: Download Failed...", - " One of the track downloads 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}") + if isinstance(e, EnvironmentError): + error_messages.append(f" {e}") else: - console.print_exception() + error_messages.append(" An unexpected error occurred in one of the download workers.",) + if hasattr(e, "returncode"): + error_messages.append(f" Binary call failed, Process exit code: {e.returncode}") + error_messages.append(" See the error trace above for more information.") + if isinstance(e, subprocess.CalledProcessError): + # CalledProcessError already lists the exception trace + console.print_exception() console.print(Padding( Group(*error_messages), (1, 5)