diff --git a/apiclient/discovery.py b/apiclient/discovery.py index 328d970..954ad6c 100644 --- a/apiclient/discovery.py +++ b/apiclient/discovery.py @@ -45,13 +45,21 @@ except ImportError: # pragma: no cover import json as simplejson -class HttpError(Exception): +class Error(Exception): + """Base error for this module.""" pass -class UnknownLinkType(Exception): +class HttpError(Error): + """HTTP data was invalid or unexpected.""" pass + +class UnknownLinkType(Error): + """Link type unknown or unexpected.""" + pass + + DISCOVERY_URI = ('http://www.googleapis.com/discovery/0.1/describe' '{?api,apiVersion}') diff --git a/apiclient/oauth.py b/apiclient/oauth.py index 8b827c6..2016dea 100644 --- a/apiclient/oauth.py +++ b/apiclient/oauth.py @@ -21,7 +21,17 @@ except ImportError: from cgi import parse_qs, parse_qsl -class MissingParameter(Exception): +class Error(Exception): + """Base error for this module.""" + pass + + +class RequestError(Error): + """Error occurred during request.""" + pass + + +class MissingParameter(Error): pass @@ -185,7 +195,7 @@ class FlowThreeLegged(object): body=body) if resp['status'] != '200': logging.error('Failed to retrieve temporary authorization: %s' % content) - raise Exception('Invalid response %s.' % resp['status']) + raise RequestError('Invalid response %s.' % resp['status']) self.request_token = dict(parse_qsl(content)) @@ -222,7 +232,7 @@ class FlowThreeLegged(object): resp, content = client.request(uri, 'POST', headers=headers) if resp['status'] != '200': logging.error('Failed to retrieve access token: %s' % content) - raise Exception('Invalid response %s.' % resp['status']) + raise RequestError('Invalid response %s.' % resp['status']) oauth_params = dict(parse_qsl(content)) token = oauth.Token( diff --git a/buzz_gae_client.py b/buzz_gae_client.py index ffc74c3..f790e02 100644 --- a/buzz_gae_client.py +++ b/buzz_gae_client.py @@ -36,6 +36,17 @@ REQUEST_TOKEN_URL = 'https://www.google.com/accounts/OAuthGetRequestToken?domain AUTHORIZE_URL = 'https://www.google.com/buzz/api/auth/OAuthAuthorizeToken?domain=anonymous&scope=https://www.googleapis.com/auth/buzz' ACCESS_TOKEN_URL = 'https://www.google.com/accounts/OAuthGetAccessToken' + +class Error(Exception): + """Base error for this module.""" + pass + + +class RequestError(Error): + """Request returned failure or unexpected data.""" + pass + + # TODO(ade) This class is really a BuzzGaeBuilder. Rename it. class BuzzGaeClient(object): def __init__(self, consumer_key='anonymous', consumer_secret='anonymous'): @@ -49,7 +60,7 @@ class BuzzGaeClient(object): if resp['status'] != '200': logging.warn('Request: %s failed with status: %s. Content was: %s' % (url, resp['status'], content)) - raise Exception('Invalid response %s.' % resp['status']) + raise RequestError('Invalid response %s.' % resp['status']) return resp, content def get_request_token(self, callback_url, display_name = None):