Skip to content

Commit

Permalink
fix: improve error logs
Browse files Browse the repository at this point in the history
Especially the "URL Not found" log which was counter productive given
it's not necessarily due to a 404.
  • Loading branch information
ThinkChaos authored and snejus committed Aug 4, 2024
1 parent 619dc24 commit ffacfe1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions beetsplug/bandcamp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def _get(self, url: str) -> str:
response = get_response(url)
try:
response.raise_for_status()
except requests.HTTPError:
self._info("URL Not found: {}", url)
except requests.HTTPError as e:
self._info("{}", e)
return ""
return unescape(response.text)

Expand All @@ -95,8 +95,8 @@ def handle_error(self, url: str) -> Iterator[Any]:
"""Return Metaguru for the given URL."""
try:
yield
except (KeyError, ValueError, AttributeError, IndexError):
self._info("Failed obtaining {}", url)
except (KeyError, ValueError, AttributeError, IndexError) as e:
self._info("Failed obtaining {}: {}", url, e)
except Exception: # pylint: disable=broad-except
i_url = "https://github.com/snejus/beetcamp/issues/new"
self._exc("Unexpected error obtaining {}, please report at {}", url, i_url)
Expand Down Expand Up @@ -292,7 +292,7 @@ def get_track_info(self, url: str) -> TrackInfo | None:

def _search(self, data: JSONDict) -> Iterable[JSONDict]:
"""Return a list of track/album URLs of type search_type matching the query."""
msg = "Searching {}s for {} using {}"
msg = "Searching releases of type '{}' for query '{}' using '{}'"
self._info(msg, data["search_type"], data["query"], str(data))
results = search_bandcamp(**data, get=self._get)
return results[: self.config["search_max"].as_number()]
Expand Down

0 comments on commit ffacfe1

Please sign in to comment.