Fix remaining 'Find Link' references and improve error messages

- Rename index page title and heading to 'Missing Link'
- Give a clear message for 429 rate limit errors
- Include response body snippet in other unexpected API errors
- Log warning when falling back to unauthenticated session

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Edward Betts 2026-05-11 14:05:35 +01:00
parent c9b4e2face
commit 2eef8f480f
2 changed files with 6 additions and 3 deletions

View file

@ -81,6 +81,7 @@ def _get_active_session() -> requests.sessions.Session:
return g.oauth_session # type: ignore[return-value]
except RuntimeError:
pass
print("WARNING: using unauthenticated session", file=sys.stderr)
return get_session()
@ -96,7 +97,9 @@ def api_get(params: StrDict) -> StrDict:
print(f"Response body: {r.text!r}", file=sys.stderr)
if webpage_error in r.text:
raise MediawikiError(webpage_error)
raise MediawikiError(f"HTTP {r.status_code}: unexpected response from Wikipedia API")
if r.status_code == 429:
raise MediawikiError("Wikipedia rate limit exceeded — wait a moment and try again.")
raise MediawikiError(f"HTTP {r.status_code}: {r.text[:200]!r}")
check_for_error(ret)
return ret