Skip to content
Snippets Groups Projects
Commit 988c0608 authored by machalekj's avatar machalekj
Browse files

Merge pull request #12 from sperrygrove/exception_hierarchy

Adds RtError super class
parents c30674f5 001b4685
No related branches found
No related tags found
No related merge requests found
......@@ -53,46 +53,51 @@ from six.moves import range
DEFAULT_QUEUE = 'General'
""" Default queue used. """
class AuthorizationError(Exception):
class RtError(Exception):
""" Super class of all Rt Errors """
pass
class AuthorizationError(RtError):
""" Exception raised when module cannot access :term:`API` due to invalid
or missing credentials. """
pass
class NotAllowed(Exception):
class NotAllowed(RtError):
""" Exception raised when request cannot be finished due to
insufficient privileges. """
pass
class UnexpectedResponse(Exception):
class UnexpectedResponse(RtError):
""" Exception raised when unexpected HTTP code is received. """
pass
class UnexpectedMessageFormat(Exception):
class UnexpectedMessageFormat(RtError):
""" Exception raised when response has bad status code (not the HTTP code,
but code in the first line of the body as 200 in `RT/4.0.7 200 Ok`)
or message parsing fails because of unexpected format. """
pass
class APISyntaxError(Exception):
class APISyntaxError(RtError):
""" Exception raised when syntax error is received. """
pass
class InvalidUse(Exception):
class InvalidUse(RtError):
""" Exception raised when API method is not used correctly. """
pass
class BadRequest(Exception):
class BadRequest(RtError):
""" Exception raised when HTTP code 400 (Bad Request) is received. """
pass
class ConnectionError(Exception):
class ConnectionError(RtError):
""" Encapsulation of various exceptions indicating network problems. """
def __init__(self, message, cause):
......@@ -104,7 +109,7 @@ class ConnectionError(Exception):
super(ConnectionError, self).__init__(message + ' (Caused by ' + repr(cause) + ")")
self.cause = cause
class InvalidQueryError(Exception):
class InvalidQueryError(RtError):
""" Exception raised when attempting to search RT with an invalid raw query. """
pass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment