Skip to content

Commit

Permalink
update: paste latest pyicloud exception classes into pyicloud_ipd/exc…
Browse files Browse the repository at this point in the history
…eptions.py
  • Loading branch information
cfurrow committed Dec 9, 2023
1 parent 91185ca commit 5f5a83f
Showing 1 changed file with 28 additions and 17 deletions.
45 changes: 28 additions & 17 deletions src/pyicloud_ipd/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,50 @@

class PyiCloudException(Exception):
pass
"""Library exceptions."""


class PyiCloudConnectionException(PyiCloudException):
pass

class PyiCloudNoDevicesException(PyiCloudException):
class PyiCloudException(Exception):
"""Generic iCloud exception."""
pass


class PyiCloudAPIResponseError(PyiCloudException):
def __init__(self, reason, code):
# API
class PyiCloudAPIResponseException(PyiCloudException):
"""iCloud response exception."""
def __init__(self, reason, code=None, retry=False):
self.reason = reason
self.code = code
message = reason
message = reason or ""
if code:
message += " (%s)" % code
if retry:
message += ". Retrying ..."

super().__init__(message)

super(PyiCloudAPIResponseError, self).__init__(message)

class PyiCloudServiceNotActivatedException(PyiCloudAPIResponseException):
"""iCloud service not activated exception."""
pass


# Login
class PyiCloudFailedLoginException(PyiCloudException):
"""iCloud failed login exception."""
pass


class PyiCloud2SARequiredError(PyiCloudException):
def __init__(self, url):
message = "Two-step authentication required for %s" % url
super(PyiCloud2SARequiredError, self).__init__(message)
class PyiCloud2SARequiredException(PyiCloudException):
"""iCloud 2SA required exception."""
def __init__(self, apple_id):
message = "Two-step authentication required for account: %s" % apple_id
super().__init__(message)


class NoStoredPasswordAvailable(PyiCloudException):
class PyiCloudNoStoredPasswordAvailableException(PyiCloudException):
"""iCloud no stored password exception."""
pass


class PyiCloudServiceNotActivatedErrror(PyiCloudAPIResponseError):
# Webservice specific
class PyiCloudNoDevicesException(PyiCloudException):
"""iCloud no device exception."""
pass

0 comments on commit 5f5a83f

Please sign in to comment.