Skip to content

Commit c68859d

Browse files
committed
fix: exception for response where error_type is not defined
1 parent 07489fc commit c68859d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

kiteconnect/connect.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,8 +925,13 @@ def _request(self, route, method, url_args=None, params=None, is_json=False, que
925925
self.session_expiry_hook()
926926

927927
# native Kite errors
928-
exp = getattr(ex, data.get("error_type"), ex.GeneralException)
929-
raise exp(data["message"], code=r.status_code)
928+
# mf error response don't have error_type field
929+
if data.get("error_type"):
930+
exp = getattr(ex, data.get("error_type"), ex.GeneralException)
931+
raise exp(data["message"], code=r.status_code)
932+
else:
933+
# Throw general exception for such undefined error type
934+
raise ex.GeneralException(data["message"], code=r.status_code)
930935

931936
return data["data"]
932937
elif "csv" in r.headers["content-type"]:

0 commit comments

Comments
 (0)