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

ValueError on method client.get_me without logging in. #184

Open
wchistow opened this issue May 21, 2024 · 1 comment
Open

ValueError on method client.get_me without logging in. #184

wchistow opened this issue May 21, 2024 · 1 comment

Comments

@wchistow
Copy link
Contributor

When I tried to call get_me() method of the Client class without passing email and password to its constructor, I got this error:

>>> import chatexchange
>>> client = chatexchange.Client()
>>> client.get_me()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../chatexchange/client.py", line 158, in get_me
    assert self._br.user_id is not None
           ^^^^^^^^^^^^^^^^
  File "/.../chatexchange/_utils.py", line 104, in __get__
    method()
  File "/.../chatexchange/browser.py", line 251, in _update_chat_fkey_and_user
    self._load_user(favorite_soup)
  File "/.../chatexchange/browser.py", line 233, in _load_user
    user_id, user_name = self.user_id_and_name_from_link(user_link_soup)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../chatexchange/browser.py", line 242, in user_id_and_name_from_link
    user_id = int(split_link[split_link.index('users') + 1])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'login?returnurl=https%3a%2f%2fchat.stackexchange.com%2fchats%2fjoin%2ffavorite'

I think, this should be not ValueError, but for example your own error something like NotLoggedInError.

@makyen
Copy link
Contributor

makyen commented May 21, 2024

While I agree that would be better in an ideal world, making that change now would be a breaking change for all existing users of this package. We definitely already look for a ValueError there, and only a ValueError, to indicate that login wasn't successful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants