Skip to content

Commit

Permalink
refactor(dl): Improve readability of download worker errors
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rlaphoenix committed Apr 24, 2024
1 parent fd64e6a commit f231000
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions devine/commands/dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,14 +547,17 @@ def result(
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)
Expand Down

0 comments on commit f231000

Please sign in to comment.