Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the raising of Exception on status code != 200 #50

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions plemmy/lemmyhttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1319,16 +1319,19 @@ def login(self, username_or_email: str,
username_or_email (str): username or email for login
password (str): password for login

Raises:
requests.ConnectionError: if no connection to server could be made

Returns:
requests.Response: result of API call
"""

form = create_form(locals())
re = post_handler(self._session, f"{self._api_url}/user/login", form)
if not isinstance(re, requests.Response):
raise requests.ConnectionError("Login failed as no connection to server could be made.")
if re.status_code == 200:
self._session = create_session(self._headers, re.json()["jwt"])
else:
raise Exception("Login failed with status code: " + str(re.status_code))
return re

def mark_all_as_read(self) -> requests.Response:
Expand Down