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

Simpler error messages #7

Open
csansone opened this issue Feb 27, 2018 · 2 comments
Open

Simpler error messages #7

csansone opened this issue Feb 27, 2018 · 2 comments

Comments

@csansone
Copy link
Owner

Wanted to see how the API responds to making an unauthorized change.

Realized that current error handling is a disaster.

>>> b2 = t.get_board('FcTw02R1')
>>> b2.name
'py-trello'
>>> b2.name = 'whatever'
ERROR:simpletrello.client:Status code 401: unauthorized permission requested on URL https://api.trello.com/1/boards/4f145d87b2f9f15d6d027b53?key=<REDACTED>&token=<REDACTED>&name=whatever
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/chris/projects/simpletrello/simpletrello/boardobject.py", line 32, in name
    response = self.put(['boards', self.id], params={'name': value})
  File "/home/chris/projects/simpletrello/simpletrello/trelloobject.py", line 28, in put
    return self.client._put(*args, **kwargs)
  File "/home/chris/projects/simpletrello/simpletrello/client.py", line 129, in _put
    params=params)
  File "/home/chris/projects/simpletrello/simpletrello/client.py", line 98, in _http_request
    response.raise_for_status()
  File "/home/chris/.virtualenvs/simpletrello3/lib/python3.4/site-packages/requests/models.py", line 935, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.trello.com/1/boards/4f145d87b2f9f15d6d027b53?key=<REDACTED>&token=<REDACTED>&name=whatever
@csansone
Copy link
Owner Author

The solution to this should be to change the import in TrelloClient to

from simpletrello import exceptions

along with defining more and better exceptions.

Finally, a catch-all for unknown exceptions.

@csansone
Copy link
Owner Author

Probably a utility function to strip the sensitive key and token data from the URL so it can still be passed, logged and/or displayed without compromising same.

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

1 participant