Jeffrey Goettsch avatar Jeffrey Goettsch committed 2927a25

Added exception classes.

Comments (0)

Files changed (1)

pushnotify/exceptions.py

+#!/usr/bin/env python
+# vim: set fileencoding=utf-8
+
+
+class PushNotifyError(Exception):
+    """Base exception for all pushnotify errors.
+
+    Args:
+        args[0]: A string containing a message from the server.
+        args[1]: An integer containing an error code from the server.
+
+    """
+
+    def __init__(self, *args):
+
+        self.args = [arg for arg in args]
+
+
+class FormatError(PushNotifyError):
+    """Raised when a request is not in the expected format.
+
+    Args:
+        args[0]: A string containing a message from the server.
+        args[1]: An integer containing an error code from the server.
+
+    """
+
+    pass
+
+
+class ApiKeyError(PushNotifyError):
+    """Raised when a provided API key is invalid
+
+    Args:
+        args[0]: A string containing a message from the server.
+        args[1]: An integer containing an error code from the server.
+
+    """
+
+    pass
+
+
+class RateLimitExceeded(PushNotifyError):
+    """Raised when too many requests are submitted in too small a time
+    frame.
+
+    Args:
+        args[0]: A string containing a message from the server.
+        args[1]: An integer containing an error code from the server.
+
+    """
+
+    pass
+
+
+class ServerError(PushNotifyError):
+    """Raised when the notification server experiences an internal error.
+
+    Args:
+        args[0]: A string containing a message from the server.
+        args[1]: An integer containing an error code from the server.
+
+    """
+
+    pass
+
+
+class UnknownError(PushNotifyError):
+    """Raised when the notification server returns an unknown error.
+
+    Args:
+        args[0]: A string containing a message from the server.
+        args[1]: An integer containing an error code from the server.
+
+    """
+
+    pass
+
+
+class UnrecognizedResponseError(PushNotifyError):
+    """Raised when the notification server returns an unrecognized
+    response.
+
+    Args:
+        args[0]: A string containing a message from the server.
+        args[1]: An integer containing an error code from the server.
+
+    """
+
+    pass
+
+
+if __name__ == '__main__':
+    pass
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.