Skip to content

Commit 13e13d8

Browse files
authored
Merge pull request #8 from fxdgear/nick/exception_handling
Unauthorized isn't imported therefore causes import error.
2 parents 9a75017 + 95ae5b6 commit 13e13d8

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)