1010from splitio .key import Key
1111from splitio .treatments import CONTROL
1212from splitio .api import SdkApi
13+ from splitio .exceptions import NetworkingException
1314
1415
1516_LOGGER = logging .getLogger (__name__ )
@@ -404,10 +405,13 @@ def _valid_apikey_type(api_key, sdk_api_base_url):
404405 'since' : - 1
405406 }
406407 headers = sdk_api ._build_headers ()
407- response = requests .get (url , params = params , headers = headers , timeout = sdk_api ._timeout )
408- if response .status_code == requests .codes .forbidden :
409- return False
410- return True
408+ try :
409+ response = requests .get (url , params = params , headers = headers , timeout = sdk_api ._timeout )
410+ if response .status_code == requests .codes .forbidden :
411+ return False
412+ return True
413+ except requests .exceptions .RequestException :
414+ raise NetworkingException ()
411415
412416
413417def validate_factory_instantiation (apikey , config , sdk_api_base_url ):
@@ -432,9 +436,12 @@ def validate_factory_instantiation(apikey, config, sdk_api_base_url):
432436 _LOGGER .error ('no ready parameter has been set - incorrect control treatments '
433437 + 'could be logged' )
434438 return False
435- if not _valid_apikey_type (apikey , sdk_api_base_url ):
436- _LOGGER .error ('factory instantiation: you passed a browser type '
437- + 'api_key, please grab an api key from the Split '
438- + 'console that is of type sdk' )
439- return False
440- return True
439+ try :
440+ if not _valid_apikey_type (apikey , sdk_api_base_url ):
441+ _LOGGER .error ('factory instantiation: you passed a browser type '
442+ + 'api_key, please grab an api key from the Split '
443+ + 'console that is of type sdk' )
444+ return False
445+ return True
446+ except NetworkingException :
447+ _LOGGER .error ("Error occured when tried to connect with Split servers" )
0 commit comments