diff --git a/bamboosdk/api/api_base.py b/bamboosdk/api/api_base.py index 87a3f982..0da8761c 100644 --- a/bamboosdk/api/api_base.py +++ b/bamboosdk/api/api_base.py @@ -44,9 +44,13 @@ def _post_request(self, module_api_path): error_msg = 'The api token is invalid' raise InvalidTokenError('Invalid token, try to refresh it', error_msg) - else: - error_msg = 'Something went wrong' - raise Exception('Something went wrong') + if response.status_code == 500: + error_msg = json.loads(response.text) + raise InternalServerError('Internal server error', error_msg) + + raise BambooHrSDKError( + 'Status code {0}'.format(response.status_code), response.text + ) def __encode_username_password(self): diff --git a/bamboosdk/exceptions.py b/bamboosdk/exceptions.py index 59a6a262..77cb6f3f 100644 --- a/bamboosdk/exceptions.py +++ b/bamboosdk/exceptions.py @@ -25,3 +25,6 @@ class NotFoundItemError(BambooHrSDKError): class InvalidTokenError(BambooHrSDKError): """Invalid or non-existing access token, 401 error""" + +class InternalServerError(BambooHrSDKError): + """Internal server error, 500 error"""