Skip to content

Commit 921a825

Browse files
Reduce logging errors
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.
1 parent c093a47 commit 921a825

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

tldextract/cache.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ def get(self, namespace: str, key: str | dict[str, Hashable]) -> object:
113113
with open(cache_filepath) as cache_file:
114114
return json.load(cache_file)
115115
except (OSError, ValueError) as exc:
116-
LOG.error("error reading TLD cache file %s: %s", cache_filepath, exc)
117-
raise KeyError("namespace: " + namespace + " key: " + repr(key)) from None
116+
raise KeyError("namespace: " + namespace + " key: " + repr(key)) from exc
118117

119118
def set( # noqa: A003
120119
self, namespace: str, key: str | dict[str, Hashable], value: object

tldextract/suffix_list.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ def find_first_response(
4747
session=session, url=url, timeout=cache_fetch_timeout
4848
)
4949
except requests.exceptions.RequestException:
50-
LOG.exception("Exception reading Public Suffix List url %s", url)
50+
LOG.warning(
51+
"Exception reading Public Suffix List url %s", url, exc_info=True
52+
)
5153
finally:
5254
# Ensure the session is always closed if it's constructed in the method
5355
if session_created:

0 commit comments

Comments
 (0)