Skip to content

Commit

Permalink
fix: exception for response where error_type is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
ranjanrak committed Jul 2, 2021
1 parent 07489fc commit 27c91da
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions kiteconnect/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,8 +925,14 @@ def _request(self, route, method, url_args=None, params=None, is_json=False, que
self.session_expiry_hook()

# native Kite errors
exp = getattr(ex, data.get("error_type"), ex.GeneralException)
raise exp(data["message"], code=r.status_code)
# mf error response don't have error_type field
if data.get("error_type"):
exp = getattr(ex, data.get("error_type"), ex.GeneralException)
raise exp(data["message"], code=r.status_code)
else:
# Throw general exception for such undefined error type
raise ex.GeneralException(data["message"], code=r.status_code)


return data["data"]
elif "csv" in r.headers["content-type"]:
Expand Down

0 comments on commit 27c91da

Please sign in to comment.