-
Notifications
You must be signed in to change notification settings - Fork 560
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update: paste latest pyicloud exception classes into pyicloud_ipd/exc…
…eptions.py
- Loading branch information
Showing
1 changed file
with
28 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |