Skip to content

Commit

Permalink
refactor: improve incomplete credentials message
Browse files Browse the repository at this point in the history
  • Loading branch information
alandtse committed Jan 24, 2020
1 parent 2355139 commit 047e529
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion teslajsonpy/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,13 @@ def generate_oauth(
elif refresh_token:
self.oauth["grant_type"] = "refresh_token"
self.oauth["refresh_token"] = refresh_token
elif not refresh_token:
raise IncompleteCredentials(
"Missing oauth authentication details: refresh token."
)
else:
raise IncompleteCredentials(
"Connection requires email and password or refresh token to authenticate."
"Missing oauth authentication details: email and password."
)

async def get(self, command):
Expand Down
3 changes: 3 additions & 0 deletions teslajsonpy/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def __init__(self, code, *args, **kwargs):
self.message = ""
super().__init__(*args, **kwargs)
self.code = code
if isinstance(code, str):
self.message = self.code
return
if self.code == 401:
self.message = "UNAUTHORIZED"
elif self.code == 404:
Expand Down

0 comments on commit 047e529

Please sign in to comment.