Skip to content

Commit 20a95ab

Browse files
committed
add _check_status_code
helper function to raise LoggedInException with specific error message based on error code
1 parent 81a3d90 commit 20a95ab

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ubiquiti/unifi.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ def __exit__(self, *args):
5252
"""
5353
self.logout()
5454

55+
def _check_status_code(code):
56+
status_codes = {400: "Invalid credentials",
57+
401: "Invalid login, or login has expired"}
58+
if code in status_codes:
59+
raise LoggedInException(status_codes[code])
60+
5561
def login(self):
5662
"""
5763
Log the user in.

0 commit comments

Comments
 (0)