Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions scripts/mediawiki_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,15 @@ def make_action(
print(f"data: {data}")
print(f"HTTP Status: {response.status_code}")
print(f'Raw response: "{response}"')
parsed_response: dict[str, Any] = response.json()
if "error" in parsed_response.keys():
raise MediaWikiSessionError(parsed_response["error"]["info"])
return parsed_response[action]
try:
parsed_response: dict[str, Any] = response.json()
if "error" in parsed_response.keys():
raise MediaWikiSessionError(parsed_response["error"]["info"])
return parsed_response[action]
except requests.JSONDecodeError:
raise MediaWikiSessionError(
f"{response.status_code} ({response.reason}): {response.text}"
)

def cooldown(self):
time.sleep(SLEEP_DURATION)
Expand Down
Loading