2020
2121import requests
2222
23- from kraken .exceptions import KrakenException
23+ from kraken .exceptions import _get_exception
2424
2525Self = TypeVar ("Self" )
2626
@@ -90,15 +90,12 @@ class KrakenErrorHandler:
9090 KrakenException based on the error message.
9191 """
9292
93- def __init__ (self : KrakenErrorHandler ) -> None :
94- self .__kexceptions : KrakenException = KrakenException ()
95-
96- def __get_exception (self : KrakenErrorHandler , msg : str ) -> Optional [Any ]:
93+ def __get_exception (self : KrakenErrorHandler , data : str ) -> Optional [Any ]:
9794 """
9895 Must be called when an error was found in the message, so the corresponding
9996 KrakenException will be returned.
10097 """
101- return self . __kexceptions . get_exception ( msg )
98+ return _get_exception ( data = data )
10299
103100 def check (self : KrakenErrorHandler , data : dict ) -> dict | Any :
104101 """
@@ -118,7 +115,7 @@ def check(self: KrakenErrorHandler, data: dict) -> dict | Any:
118115 if len (data .get ("error" , [])) == 0 and "result" in data :
119116 return data ["result" ]
120117
121- exception = self .__get_exception (data ["error" ])
118+ exception : Type [ Exception ] = self .__get_exception (data = data ["error" ])
122119 if exception :
123120 raise exception (data )
124121 return data
@@ -135,7 +132,7 @@ def check_send_status(self: KrakenErrorHandler, data: dict) -> dict:
135132 :rtype: dict
136133 """
137134 if "sendStatus" in data and "status" in data ["sendStatus" ]:
138- exception : Type [KrakenException ] = self .__get_exception (
135+ exception : Type [Exception ] = self .__get_exception (
139136 data ["sendStatus" ]["status" ],
140137 )
141138 if exception :
@@ -158,7 +155,7 @@ def check_batch_status(self: KrakenErrorHandler, data: dict) -> dict:
158155 batch_status : list [dict [str , Any ]] = data ["batchStatus" ]
159156 for status in batch_status :
160157 if "status" in status :
161- exception : Type [KrakenException ] = self .__get_exception (
158+ exception : Type [Exception ] = self .__get_exception (
162159 status ["status" ],
163160 )
164161 if exception :
@@ -263,9 +260,10 @@ def _request( # noqa: PLR0913
263260 )
264261
265262 method = method .upper ()
266- data_json : str = ""
267263 if method in ("GET" , "DELETE" ) and params :
268- data_json = "&" .join ([f"{ key } ={ params [key ]} " for key in sorted (params )])
264+ data_json : str = "&" .join (
265+ [f"{ key } ={ params [key ]} " for key in sorted (params )],
266+ )
269267 uri += f"?{ data_json } " .replace (" " , "%20" )
270268
271269 headers : dict = {}
0 commit comments