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:
parent
c9b4e2face
commit
2eef8f480f
2 changed files with 6 additions and 3 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue