From c68859d95bc3ce81bd50130c61473a4c38cb0641 Mon Sep 17 00:00:00 2001 From: Rakesh R Date: Fri, 2 Jul 2021 15:18:48 +0530 Subject: [PATCH] fix: exception for response where error_type is not defined --- kiteconnect/connect.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kiteconnect/connect.py b/kiteconnect/connect.py index 0473a368..3ec6de5f 100644 --- a/kiteconnect/connect.py +++ b/kiteconnect/connect.py @@ -925,8 +925,13 @@ 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"]: