Skip to content
Merged
8 changes: 6 additions & 2 deletions domaintools/base_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,16 @@ def data(self):
return self._data

def check_limit_exceeded(self):
limit_exceeded, reason = False, ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a pedantic change:

can we put the Limit Exceeded as default reason? so we dont need to define it in elif and just concat the message in the if statement.

Overall, LGTM ✅ . Nice!!

if isinstance(self._data, dict) and (
"response" in self._data and "limit_exceeded" in self._data["response"] and self._data["response"]["limit_exceeded"] is True
):
raise ServiceException(503, f"Limit Exceeded: {self._data['response']['message']}")
limit_exceeded, reason = True, f"Limit Exceeded: {self._data['response']['message']}"
elif "response" in self._data and "limit_exceeded" in self._data:
raise ServiceException(503, "Limit Exceeded")
limit_exceeded, reason = True, "Limit Exceeded"

if limit_exceeded:
raise ServiceException(503, reason)

@property
def status(self):
Expand Down
Loading