Skip to content

Commit e4e4281

Browse files
thodson-usgsclaude
andcommitted
Apply Copilot PR #273 review: logger.error + future-proof helper docstring
Two small follow-ups from Copilot's review of 9c6481f: - Revert `logger.exception` -> `logger.error` in both `_walk_pages` and `get_stats_data` except blocks. The PR description always advertised `logger.error("Request incomplete: %s", e)`; the simplify pass had switched to `logger.exception(...)` (which auto-attaches a traceback) but mid-pagination failures are expected, best-effort cases — the exception text is already in the message via `%s`, and a per-page traceback would be noisy. Reverting matches the PR description and the original intent. - Drop the literal count from `_error_log_messages`'s docstring. The prior wording ("the four pagination-failure tests below") was already stale-prone, and Copilot flagged it. Replaced with a count-free phrasing so future test additions don't render it misleading. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9c6481f commit e4e4281

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

dataretrieval/waterdata/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ def _walk_pages(
683683
dfs.append(_get_resp_data(resp, geopd=geopd))
684684
curr_url = _next_req_url(resp)
685685
except Exception as e: # noqa: BLE001
686-
logger.exception("Request incomplete: %s", e)
686+
logger.error("Request incomplete: %s", e)
687687
logger.warning(
688688
"Request failed for URL: %s. Data download interrupted.", curr_url
689689
)
@@ -1147,7 +1147,7 @@ def get_stats_data(
11471147
all_dfs.append(_handle_stats_nesting(body, geopd=GEOPANDAS))
11481148
next_token = body["next"]
11491149
except Exception as e: # noqa: BLE001
1150-
logger.exception("Request incomplete: %s", e)
1150+
logger.error("Request incomplete: %s", e)
11511151
logger.warning(
11521152
"Request failed for URL: %s (next_token=%s). "
11531153
"Data download interrupted.",

tests/waterdata_utils_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ def _resp_ok(features):
107107

108108

109109
def _error_log_messages(caplog):
110-
"""Pull ERROR-and-above message strings out of caplog. The four
111-
pagination-failure tests below all assert against the same shape."""
110+
"""Pull ERROR-and-above message strings out of caplog. The pagination-
111+
failure tests below all assert against the same shape."""
112112
return [r.getMessage() for r in caplog.records if r.levelno >= logging.ERROR]
113113

114114

0 commit comments

Comments
 (0)