From fbe78308eb4887ad81eee5af6c57bdd2c9523d8c Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Wed, 1 Mar 2023 10:02:38 +0000 Subject: [PATCH] Handle download worker exceptions outside thread loop This is so that I can start to log information after the track listing. It's also not necessary to have the try catch within the loop, when both methods will have exited the loop. --- 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 7dfaaf3..e134b10 100644 --- a/devine/commands/dl.py +++ b/devine/commands/dl.py @@ -34,6 +34,7 @@ from rich.rule import Rule from rich.table import Table from rich.text import Text from rich.tree import Tree +from rich.console import Group from devine.core.config import config from devine.core.console import console @@ -474,19 +475,24 @@ class dl: ) for i, track in enumerate(title.tracks) )): - try: - download.result() - except Exception: # noqa - self.DL_POOL_STOP.set() - self.log.error("Download worker threw an unhandled exception:") - console.print_exception() - return + download.result() except KeyboardInterrupt: console.print(Padding( ":x: Download Cancelled...", (0, 5, 1, 5) )) return + except Exception: # noqa + 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." + ), + (1, 5) + )) + return video_track_n = 0