Skip to content

Commit

Permalink
Reduce logging errors
Browse files Browse the repository at this point in the history
The library can continue functioning in these cases, so "error" is inappropriate. Either include traceback info in the raised exception and let the caller decide whether it is a true error, or reduce the log level to warning.
  • Loading branch information
john-kurkowski committed Jul 6, 2024
1 parent c093a47 commit 921a825
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 1 addition & 2 deletions tldextract/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ def get(self, namespace: str, key: str | dict[str, Hashable]) -> object:
with open(cache_filepath) as cache_file:
return json.load(cache_file)
except (OSError, ValueError) as exc:
LOG.error("error reading TLD cache file %s: %s", cache_filepath, exc)
raise KeyError("namespace: " + namespace + " key: " + repr(key)) from None
raise KeyError("namespace: " + namespace + " key: " + repr(key)) from exc

def set( # noqa: A003
self, namespace: str, key: str | dict[str, Hashable], value: object
Expand Down
4 changes: 3 additions & 1 deletion tldextract/suffix_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ def find_first_response(
session=session, url=url, timeout=cache_fetch_timeout
)
except requests.exceptions.RequestException:
LOG.exception("Exception reading Public Suffix List url %s", url)
LOG.warning(
"Exception reading Public Suffix List url %s", url, exc_info=True
)
finally:
# Ensure the session is always closed if it's constructed in the method
if session_created:
Expand Down

0 comments on commit 921a825

Please sign in to comment.