Add error classes for apiclient.discovery and apiclient.oauth
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 @@
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 @@
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 @@
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 @@
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(