I'm utilizing the following code to print exceptions from a python module I'm running inside of my script:
except Exception as e:
logging.info('yt-dlp initated a break', exc_info=True)
Currently it outputs much more information than I need.
Something along the lines of:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/web_ripper.py", line 58, in subscriptions_loop
ydl.download([url])
File "/app/venv/lib/python3.9/site-packages/yt_dlp/YoutubeDL.py", line 3113, in download
self.__download_wrapper(self.extract_info)(
File "/app/venv/lib/python3.9/site-packages/yt_dlp/YoutubeDL.py", line 3086, in wrapper
res = func(*args, **kwargs)
File "/app/venv/lib/python3.9/site-packages/yt_dlp/YoutubeDL.py", line 1344, in extract_info
return self.__extract_info(url, self.get_info_extractor(ie_key), download, extra_info, process)
File "/app/venv/lib/python3.9/site-packages/yt_dlp/YoutubeDL.py", line 1371, in wrapper
self.report_error(str(e), e.format_traceback())
File "/app/venv/lib/python3.9/site-packages/yt_dlp/YoutubeDL.py", line 912, in report_error
self.trouble(f'{self._format_err("ERROR:", self.Styles.ERROR)} {message}', *args, **kwargs)
File "/app/venv/lib/python3.9/site-packages/yt_dlp/YoutubeDL.py", line 853, in trouble
raise DownloadError(message, exc_info)
yt_dlp.utils.DownloadError: ERROR: [youtube:tab] Videogamedunkey: Unable to download API page: HTTP Error 404: Not Found
What's the most efficient way to simply print the last line of the exception?