Exceptions¶
All exceptions raised by PyiCloud derive from PyiCloudException, so a single
except PyiCloudException block catches everything the library raises.
Library exceptions.
PyiCloudException
¶
Bases: Exception
Generic iCloud exception.
Source code in pyicloud/exceptions.py
12 13 | |
PyiCloudPasswordException
¶
Bases: PyiCloudException
Password exception.
Source code in pyicloud/exceptions.py
16 17 | |
PyiCloudServiceUnavailable
¶
Bases: PyiCloudException
Service unavailable exception.
Source code in pyicloud/exceptions.py
20 21 | |
TokenException
¶
Bases: PyiCloudException
Token exception.
Source code in pyicloud/exceptions.py
24 25 | |
PyiCloudAPIResponseException
¶
Bases: PyiCloudException
iCloud response exception.
Source code in pyicloud/exceptions.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
PyiCloudServiceNotActivatedException
¶
Bases: PyiCloudAPIResponseException
iCloud service not activated exception.
Source code in pyicloud/exceptions.py
61 62 | |
PyiCloudPCSTimeoutException
¶
Bases: PyiCloudAPIResponseException
Raised when PCS access could not be granted after all retries.
Source code in pyicloud/exceptions.py
65 66 | |
PyiCloudConnectionException
¶
Bases: PyiCloudAPIResponseException
Raised when iCloud could not be reached at all.
A connection error, DNS failure or timeout says nothing about whether the caller's credentials or session are still good, only that no answer came back. Callers need to tell the two apart because the remedies are opposite: a rejected password is fixed by asking the user to log in again, while an unreachable service is fixed by waiting and retrying.
Distinguishing it matters most during authentication, where every transport failure used to be reported as a failed login. A consumer acting on that asks the user to re-enter working credentials in the middle of an outage, and, if it stops polling until they do, stays down long after iCloud has come back.
Subclasses the generic response error so existing handlers keep catching
it, and carries no code because no HTTP response was received.
Source code in pyicloud/exceptions.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
PyiCloudEndpointGoneException
¶
Bases: PyiCloudAPIResponseException
Raised when Apple reports an endpoint as permanently gone (HTTP 410).
Apple withdraws endpoints without notice, and has done so more than once. A 410 means the endpoint this library calls no longer exists, so it signals that pyicloud needs updating rather than that the caller's request, credentials, or session were wrong.
Distinguishing it matters because the alternative is expensive: when the Photos upload endpoint was withdrawn it surfaced as a generic response error, and the reporter ruled out a stale session, an outdated client, a missing PCS handshake, the wrong dsid, and the wrong partition before concluding the endpoint itself had gone.
endpoint is a redacted host-and-path label safe to quote in a bug
report; the full URL and the response body are available on response
when one was captured.
Source code in pyicloud/exceptions.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
PyiCloudFailedLoginException
¶
Bases: PyiCloudException
iCloud failed login exception.
Source code in pyicloud/exceptions.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
PyiCloudAccountLockedException
¶
Bases: PyiCloudFailedLoginException
Apple rejected authentication because the account is locked.
The iCloud sign-in flow directs locked accounts to this unlock URL. Apple
determines the required verification steps. Replace
{url_encoded_apple_account} with the URL-encoded Apple Account:
https://iforgot.apple.com/password/verify/appleid?returnUrl=https%3A%2F%2Fwww.icloud.com%2F&prs_account_nm={url_encoded_apple_account}&unlock=true.
Source code in pyicloud/exceptions.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
PyiCloudAcceptTermsException
¶
Bases: PyiCloudException
iCloud accept terms exception.
Source code in pyicloud/exceptions.py
166 167 | |
PyiCloud2FARequiredException
¶
Bases: PyiCloudException
iCloud 2FA required exception.
Source code in pyicloud/exceptions.py
170 171 172 173 174 175 176 177 | |
PyiCloud2SARequiredException
¶
Bases: PyiCloudException
iCloud 2SA required exception.
Source code in pyicloud/exceptions.py
180 181 182 183 184 185 186 | |
PyiCloudAuthRequiredException
¶
Bases: PyiCloudException
iCloud re-authentication required exception.
Source code in pyicloud/exceptions.py
189 190 191 192 193 194 195 196 | |
PyiCloudNoTrustedNumberAvailable
¶
Bases: PyiCloudException
iCloud no trusted number exception.
Source code in pyicloud/exceptions.py
199 200 | |
PyiCloudTrustedDevicePromptException
¶
Bases: PyiCloudAPIResponseException
Trusted-device prompt bootstrap exception.
Source code in pyicloud/exceptions.py
203 204 | |
PyiCloudTrustedDeviceVerificationException
¶
Bases: PyiCloudAPIResponseException
Trusted-device bridge verification exception.
Source code in pyicloud/exceptions.py
207 208 | |
PyiCloudTrustedDeviceChallengeRequiredException
¶
Bases: PyiCloudTrustedDeviceVerificationException
The active 2FA challenge is unusable and a replacement must be requested.
Raised when a trusted-device bridge challenge has been consumed or cannot be verified. Retrying without a fresh challenge would silently fall back to the legacy verifier, so callers should request and deliver a new code first.
Source code in pyicloud/exceptions.py
211 212 213 214 215 216 217 218 219 | |
PyiCloudSecurityKeyException
¶
Bases: PyiCloudException
Security key confirmation exception.
Source code in pyicloud/exceptions.py
222 223 | |
PyiCloudSecurityKeyTimeoutException
¶
Bases: PyiCloudSecurityKeyException
Security key confirmation cancelled or timed out before the key was touched.
Source code in pyicloud/exceptions.py
226 227 | |
PyiCloudNoStoredPasswordAvailableException
¶
Bases: PyiCloudException
iCloud no stored password exception.
Source code in pyicloud/exceptions.py
230 231 | |
PyiCloudNoDevicesException
¶
Bases: PyiCloudException
iCloud no device exception.
Source code in pyicloud/exceptions.py
235 236 | |
is_server_error(error)
¶
Whether an API error carries an Apple HTTP 5xx response.
Source code in pyicloud/exceptions.py
52 53 54 55 56 57 58 | |