11import json
2- from typing import List , Optional , Set
2+ from typing import List , Set
3+
4+ from beartype import beartype
35
46from cript .exceptions import CRIPTException
57
@@ -215,10 +217,11 @@ class APIError(CRIPTException):
215217 api_error : str = ""
216218
217219 # having the URL that the API gave an error for helps in debugging
218- api_url : Optional [ str ] = None
219- http_method : Optional [ str ] = None
220+ api_url : str = ""
221+ http_method : str = ""
220222
221- def __init__ (self , api_error : str , http_method : Optional [str ] = None , api_url : Optional [str ] = None ) -> None :
223+ @beartype
224+ def __init__ (self , api_error : str , http_method : str , api_url : str ) -> None :
222225 self .api_error = api_error
223226
224227 self .api_url = api_url
@@ -228,14 +231,7 @@ def __init__(self, api_error: str, http_method: Optional[str] = None, api_url: O
228231 self .http_method = http_method
229232
230233 def __str__ (self ) -> str :
231- # TODO refactor all of SDK using this error to be used the same to avoid this logic and Optional attributes
232- # this logic currently exists to make previous SDK work
233-
234- # if you have the URL then display it, otherwise just show the error message
235- if self .api_url and self .http_method :
236- return f"CRIPT Python SDK sent HTTP `{ self .http_method .upper ()} ` request to URL: `{ self .api_url } ` and API responded with { self .api_error } "
237- else :
238- return f"The API responded with: { self .api_error } "
234+ return f"CRIPT Python SDK sent HTTP `{ self .http_method .upper ()} ` request to URL: `{ self .api_url } ` and API responded with { self .api_error } "
239235
240236
241237class FileDownloadError (CRIPTException ):
0 commit comments