Skip to content

Commit

Permalink
Merge pull request #187 from Onebrownsound/api-2663
Browse files Browse the repository at this point in the history
Ward off unexpected missing properties when handling exceptions
  • Loading branch information
hedyyytang authored May 9, 2024
2 parents 0675bf8 + ea52148 commit 4475b61
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions vimeo/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,22 @@ class BaseVimeoException(Exception):

def __get_message(self, response):
if type(response) is Exception:
return response.message
default_message = 'There was an unexpected error'
return response.message if response.message is not None else default_message

json = None
try:
json = response.json()
except Exception:
pass

message = None
if json:
message = json.get('error') or json.get('Description')
elif hasattr(response, 'text'):
response_message = getattr(response, 'message', 'There was an unexpected error.')
message = getattr(response, 'text', response_message)
else:
elif hasattr(response, 'message')::
message = getattr(response, 'message')

return message
Expand Down

0 comments on commit 4475b61

Please sign in to comment.