Skip to content

Commit

Permalink
resolved comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashutosh619-sudo committed Dec 13, 2023
1 parent e2e45dd commit 0427fac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 7 additions & 3 deletions bamboosdk/api/api_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions bamboosdk/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

0 comments on commit 0427fac

Please sign in to comment.