Skip to content

Commit 95ae5b6

Browse files
committed
Unauthorized isn't imported therefore causes import error.
Changing to use HttpException and pass in the parameters there solves this problem and doesn't require any additional code. closes: #7
1 parent 9a75017 commit 95ae5b6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

swiftype/swiftype.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
DEFAULT_API_HOST = 'api.swiftype.com'
2020
DEFAULT_API_BASE_PATH = '/api/v1/'
2121

22+
2223
class Client(object):
2324

2425
def __init__(self, username=None, password=None, api_key=None, access_token=None, client_id=None, client_secret=None, host=DEFAULT_API_HOST):
@@ -229,7 +230,7 @@ def _request(self, method, path, params={}, data={}):
229230
elif self.__api_key is not None:
230231
params['auth_token'] = self.__api_key
231232
else:
232-
raise Unauthorized('Authorization required.')
233+
raise HttpException(401, 'Authorization required.')
233234

234235
full_path = self.__base_path + path + '.json'
235236
query = urlencode(params, True)
@@ -253,7 +254,7 @@ def _request(self, method, path, params={}, data={}):
253254
else:
254255
ret = {'status': response.status }
255256
elif response.status == 401:
256-
raise Unauthorized('Authorization required.')
257+
raise HttpException( response.status, 'Authorization required.')
257258
else:
258259
raise HttpException(response.status, response.body)
259260
connection.close()

0 commit comments

Comments
 (0)