1from __future__ import absolute_import, division, print_function, unicode_literals
2
3
4class DiscogsAPIError(Exception):
5    """Root Exception class for Discogs API errors."""
6    pass
7
8
9class ConfigurationError(DiscogsAPIError):
10    """Exception class for problems with the configuration of this client."""
11    def __init__(self, msg):
12        self.msg = msg
13
14    def __str__(self):
15        return self.msg
16
17
18class HTTPError(DiscogsAPIError):
19    """Exception class for HTTP errors."""
20    def __init__(self, message, code):
21        self.status_code = code
22        self.msg = '{0}: {1}'.format(code, message)
23
24    def __str__(self):
25        return self.msg
26
27
28class AuthorizationError(HTTPError):
29    """The server rejected the client's credentials."""
30    def __init__(self, message, code, response):
31        super(AuthorizationError, self).__init__(message, code)
32        self.msg = '{0} Response: {1!r}'.format(self.msg, response)
33