Skip to content

Commit

Permalink
directly pass exception instances as 'exc_info' logger argument
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Sep 19, 2024
1 parent dd56bb2 commit a051e1c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
10 changes: 5 additions & 5 deletions gallery_dl/downloader/ytdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def download(self, url, pathfmt):
except (ImportError, SyntaxError) as exc:
self.log.error("Cannot import module '%s'",
getattr(exc, "name", ""))
self.log.debug("", exc_info=True)
self.log.debug("", exc_info=exc)
self.download = lambda u, p: False
return False
self.ytdl_instance = ytdl_instance = ytdl.construct_YoutubeDL(
Expand All @@ -64,8 +64,8 @@ def download(self, url, pathfmt):
if not info_dict:
try:
info_dict = ytdl_instance.extract_info(url[5:], download=False)
except Exception:
pass
except Exception as exc:
self.log.debug("", exc_info=exc)
if not info_dict:
return False

Expand Down Expand Up @@ -120,8 +120,8 @@ def _download_video(self, ytdl_instance, pathfmt, info_dict):
self.out.start(pathfmt.path)
try:
ytdl_instance.process_info(info_dict)
except Exception:
self.log.debug("Traceback", exc_info=True)
except Exception as exc:
self.log.debug("", exc_info=exc)
return False
return True

Expand Down
2 changes: 1 addition & 1 deletion gallery_dl/extractor/8chan.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def items(self):
self.cookies = self.cookies_prepare()
except Exception as exc:
self.log.debug("Failed to fetch captcha cookies: %s: %s",
exc.__class__.__name__, exc, exc_info=True)
exc.__class__.__name__, exc, exc_info=exc)

# download files
posts = thread.pop("posts", ())
Expand Down
6 changes: 4 additions & 2 deletions gallery_dl/extractor/flickr.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ def items(self):
extract = self.api._extract_format
for photo in self.photos():
try:
1/0
photo = extract(photo)
except Exception as exc:
self.log.warning(
"Skipping %s (%s)", photo["id"], exc.__class__.__name__)
self.log.debug("", exc_info=True)
"Skipping photo %s (%s: %s)",
photo["id"], exc.__class__.__name__, exc)
self.log.debug("", exc_info=exc)
else:
photo.update(data)
url = photo["url"]
Expand Down
4 changes: 2 additions & 2 deletions gallery_dl/extractor/newgrounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def items(self):
try:
post = self.extract_post(post_url)
url = post.get("url")
except Exception:
self.log.debug("", exc_info=True)
except Exception as exc:
self.log.debug("", exc_info=exc)
url = None

if url:
Expand Down
8 changes: 4 additions & 4 deletions gallery_dl/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,20 @@ def run(self):
raise
except exception.GalleryDLException as exc:
log.error("%s: %s", exc.__class__.__name__, exc)
log.debug("", exc_info=True)
log.debug("", exc_info=exc)
self.status |= exc.code
except OSError as exc:
log.error("Unable to download data: %s: %s",
exc.__class__.__name__, exc)
log.debug("", exc_info=True)
log.debug("", exc_info=exc)
self.status |= 128
except Exception as exc:
log.error(("An unexpected error occurred: %s - %s. "
"Please run gallery-dl again with the --verbose flag, "
"copy its output and report this issue on "
"https://github.com/mikf/gallery-dl/issues ."),
exc.__class__.__name__, exc)
log.debug("", exc_info=True)
log.debug("", exc_info=exc)
self.status |= 1
except BaseException:
self.status |= 1
Expand Down Expand Up @@ -642,7 +642,7 @@ def initialize(self, kwdict=None):
except Exception as exc:
pp_log.error("'%s' initialization failed: %s: %s",
name, exc.__class__.__name__, exc)
pp_log.debug("", exc_info=True)
pp_log.debug("", exc_info=exc)
else:
pp_list.append(pp_obj)

Expand Down
3 changes: 2 additions & 1 deletion gallery_dl/postprocessor/ugoira.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,12 @@ def convert_to_animation(self, pathfmt, tempdir):
print()
self.log.error("Unable to invoke FFmpeg (%s: %s)",
exc.__class__.__name__, exc)
self.log.debug("", exc_info=exc)
pathfmt.realpath = pathfmt.temppath
except Exception as exc:
print()
self.log.error("%s: %s", exc.__class__.__name__, exc)
self.log.debug("", exc_info=True)
self.log.debug("", exc_info=exc)
pathfmt.realpath = pathfmt.temppath
else:
if self.mtime:
Expand Down

0 comments on commit a051e1c

Please sign in to comment.