Update list of exceptions
This commit is contained in:
+106
-75
@@ -2,6 +2,10 @@ class APNsException(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ConnectionFailed(APNsException):
|
||||||
|
"""There was an error connecting to APNs."""
|
||||||
|
|
||||||
|
|
||||||
class InternalException(APNsException):
|
class InternalException(APNsException):
|
||||||
"""This exception should not be raised. If it is, please report this as a bug."""
|
"""This exception should not be raised. If it is, please report this as a bug."""
|
||||||
pass
|
pass
|
||||||
@@ -12,44 +16,8 @@ class BadPayloadException(APNsException):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class PayloadEmpty(BadPayloadException):
|
class BadCollapseId(BadPayloadException):
|
||||||
"""The message payload was empty."""
|
"""The collapse identifier exceeds the maximum allowed size"""
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class PayloadTooLarge(BadPayloadException):
|
|
||||||
"""The message payload was too large. The maximum payload size is 4096 bytes."""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class BadTopic(BadPayloadException):
|
|
||||||
"""The apns-topic was invalid."""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class TopicDisallowed(BadPayloadException):
|
|
||||||
"""Pushing to this topic is not allowed."""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class BadMessageId(InternalException):
|
|
||||||
"""The apns-id value is bad."""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class BadExpirationDate(BadPayloadException):
|
|
||||||
"""The apns-expiration value is bad."""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class BadPriority(InternalException):
|
|
||||||
"""The apns-priority value is bad."""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class MissingDeviceToken(APNsException):
|
|
||||||
"""The device token is not specified in the request :path.
|
|
||||||
Verify that the :path header contains the device token."""
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@@ -59,21 +27,60 @@ class BadDeviceToken(APNsException):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class BadExpirationDate(BadPayloadException):
|
||||||
|
"""The apns-expiration value is bad."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class BadMessageId(InternalException):
|
||||||
|
"""The apns-id value is bad."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class BadPriority(InternalException):
|
||||||
|
"""The apns-priority value is bad."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class BadTopic(BadPayloadException):
|
||||||
|
"""The apns-topic was invalid."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class DeviceTokenNotForTopic(APNsException):
|
class DeviceTokenNotForTopic(APNsException):
|
||||||
"""The device token does not match the specified topic."""
|
"""The device token does not match the specified topic."""
|
||||||
|
|
||||||
|
|
||||||
class Unregistered(APNsException):
|
|
||||||
"""The device token is inactive for the specified topic."""
|
|
||||||
|
|
||||||
|
|
||||||
class DuplicateHeaders(InternalException):
|
class DuplicateHeaders(InternalException):
|
||||||
"""One or more headers were repeated."""
|
"""One or more headers were repeated."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class BadCertificateEnvironment(APNsException):
|
class IdleTimeout(APNsException):
|
||||||
"""The client certificate was for the wrong environment."""
|
"""Idle time out."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class MissingDeviceToken(APNsException):
|
||||||
|
"""The device token is not specified in the request :path.
|
||||||
|
Verify that the :path header contains the device token."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class MissingTopic(BadPayloadException):
|
||||||
|
"""The apns-topic header of the request was not specified and was required.
|
||||||
|
The apns-topic header is mandatory when the client is connected using a certificate
|
||||||
|
that supports multiple topics."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class PayloadEmpty(BadPayloadException):
|
||||||
|
"""The message payload was empty."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TopicDisallowed(BadPayloadException):
|
||||||
|
"""Pushing to this topic is not allowed."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@@ -82,11 +89,32 @@ class BadCertificate(APNsException):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class BadCertificateEnvironment(APNsException):
|
||||||
|
"""The client certificate was for the wrong environment."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ExpiredProviderToken(APNsException):
|
||||||
|
"""The provider token is stale and a new token should be generated."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Forbidden(APNsException):
|
class Forbidden(APNsException):
|
||||||
"""The specified action is not allowed."""
|
"""The specified action is not allowed."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class InvalidProviderToken(APNsException):
|
||||||
|
"""The provider token is not valid or the token signature could not be verified."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class MissingProviderToken(APNsException):
|
||||||
|
"""No provider certificate was used to connect to APNs and Authorization header was missing or no provider token
|
||||||
|
was specified. """
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class BadPath(APNsException):
|
class BadPath(APNsException):
|
||||||
"""The request contained a bad :path value."""
|
"""The request contained a bad :path value."""
|
||||||
pass
|
pass
|
||||||
@@ -97,21 +125,25 @@ class MethodNotAllowed(InternalException):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Unregistered(APNsException):
|
||||||
|
"""The device token is inactive for the specified topic."""
|
||||||
|
|
||||||
|
|
||||||
|
class PayloadTooLarge(BadPayloadException):
|
||||||
|
"""The message payload was too large. The maximum payload size is 4096 bytes."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TooManyProviderTokenUpdates(APNsException):
|
||||||
|
"""The provider token is being updated too often."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TooManyRequests(APNsException):
|
class TooManyRequests(APNsException):
|
||||||
"""Too many requests were made consecutively to the same device token."""
|
"""Too many requests were made consecutively to the same device token."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class IdleTimeout(APNsException):
|
|
||||||
"""Idle time out."""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class Shutdown(APNsException):
|
|
||||||
"""The server is shutting down."""
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class InternalServerError(APNsException):
|
class InternalServerError(APNsException):
|
||||||
"""An internal server error occurred."""
|
"""An internal server error occurred."""
|
||||||
pass
|
pass
|
||||||
@@ -122,40 +154,39 @@ class ServiceUnavailable(APNsException):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class MissingTopic(BadPayloadException):
|
class Shutdown(APNsException):
|
||||||
"""The apns-topic header of the request was not specified and was required.
|
"""The server is shutting down."""
|
||||||
The apns-topic header is mandatory when the client is connected using a certificate
|
|
||||||
that supports multiple topics."""
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ConnectionFailed(APNsException):
|
|
||||||
"""There was an error connecting to APNs."""
|
|
||||||
|
|
||||||
|
|
||||||
def exception_class_for_reason(reason):
|
def exception_class_for_reason(reason):
|
||||||
return {
|
return {
|
||||||
'PayloadEmpty': PayloadEmpty,
|
'BadCollapseId': BadCollapseId,
|
||||||
'PayloadTooLarge': PayloadTooLarge,
|
|
||||||
'BadTopic': BadTopic,
|
|
||||||
'TopicDisallowed': TopicDisallowed,
|
|
||||||
'BadMessageId': BadMessageId,
|
|
||||||
'BadExpirationDate': BadExpirationDate,
|
|
||||||
'BadPriority': BadPriority,
|
|
||||||
'MissingDeviceToken': MissingDeviceToken,
|
|
||||||
'BadDeviceToken': BadDeviceToken,
|
'BadDeviceToken': BadDeviceToken,
|
||||||
|
'BadExpirationDate': BadExpirationDate,
|
||||||
|
'BadMessageId': BadMessageId,
|
||||||
|
'BadPriority': BadPriority,
|
||||||
|
'BadTopic': BadTopic,
|
||||||
'DeviceTokenNotForTopic': DeviceTokenNotForTopic,
|
'DeviceTokenNotForTopic': DeviceTokenNotForTopic,
|
||||||
'Unregistered': Unregistered,
|
|
||||||
'DuplicateHeaders': DuplicateHeaders,
|
'DuplicateHeaders': DuplicateHeaders,
|
||||||
'BadCertificateEnvironment': BadCertificateEnvironment,
|
'IdleTimeout': IdleTimeout,
|
||||||
|
'MissingDeviceToken': MissingDeviceToken,
|
||||||
|
'MissingTopic': MissingTopic,
|
||||||
|
'PayloadEmpty': PayloadEmpty,
|
||||||
|
'TopicDisallowed': TopicDisallowed,
|
||||||
'BadCertificate': BadCertificate,
|
'BadCertificate': BadCertificate,
|
||||||
|
'BadCertificateEnvironment': BadCertificateEnvironment,
|
||||||
|
'ExpiredProviderToken': ExpiredProviderToken,
|
||||||
'Forbidden': Forbidden,
|
'Forbidden': Forbidden,
|
||||||
|
'InvalidProviderToken': InvalidProviderToken,
|
||||||
|
'MissingProviderToken': MissingProviderToken,
|
||||||
'BadPath': BadPath,
|
'BadPath': BadPath,
|
||||||
'MethodNotAllowed': MethodNotAllowed,
|
'MethodNotAllowed': MethodNotAllowed,
|
||||||
|
'Unregistered': Unregistered,
|
||||||
|
'PayloadTooLarge': PayloadTooLarge,
|
||||||
|
'TooManyProviderTokenUpdates': TooManyProviderTokenUpdates,
|
||||||
'TooManyRequests': TooManyRequests,
|
'TooManyRequests': TooManyRequests,
|
||||||
'IdleTimeout': IdleTimeout,
|
|
||||||
'Shutdown': Shutdown,
|
|
||||||
'InternalServerError': InternalServerError,
|
'InternalServerError': InternalServerError,
|
||||||
'ServiceUnavailable': ServiceUnavailable,
|
'ServiceUnavailable': ServiceUnavailable,
|
||||||
'MissingTopic': MissingTopic,
|
'Shutdown': Shutdown,
|
||||||
}[reason]
|
}[reason]
|
||||||
|
|||||||
Reference in New Issue
Block a user