1 class DocError(Exception):
2 def __init__(self, message, doc):
3 super().__init__(message)
7 The document returned by the API that brought about this error.
11 class APIError(DocError):
12 def __init__(self, doc):
14 code = doc.get('error', {}).get('code')
15 message = doc.get('error', {}).get('message')
17 super().__init__("{0}:{1}".format(code, message), doc)
21 The error code returned by the api -- if available.
24 self.message = message
26 The error message returned by the api -- if available.
29 class AuthenticationError(DocError):
30 def __init__(self, doc):
31 result = doc['login']['result']
32 super().__init__(result, doc)
36 The result code of an authentication attempt.
40 class MalformedResponse(DocError):
41 def __init__(self, key, doc):
43 super().__init__("Expected to find '{0}' in result.".format(key), doc)
47 The expected, but missing key from the API call.