Open henryruhs opened 5 years ago
Hello,
passing various invalid strings to the constructor is causing different errors and exceptions:
ip = 1.1.1
ip = 1.1.1.1
PhueRequestTimeout
socket.timeout
line 743, in connect
line 652, in request
it would be nice to have the following exceptions to be thrown:
Bridge()
PhueConnectionException
PhueTimeoutException
PhueRegistrationException
Hacky solution that is currently working properly accept random socket.timeout:
def bridge_factory(ip): bridge = None # handle import try: from phue import Bridge, PhueRegistrationException, PhueRequestTimeout except ImportError: exit(wording.get('package_no').format('PHUE') + wording.get('exclamation_mark')) # create instance try: bridge = Bridge(ip) except (PhueRequestTimeout, OSError, ValueError): exit(wording.get('connection_no').format('PHILIPS HUE') + wording.get('exclamation_mark')) except PhueRegistrationException: exit(wording.get('press_button').format('PAIRING', 'PHILIPS HUE BRIDGE') + wording.get('exclamation_mark')) return bridge
Wanted solution that throws PhueConnectionException, PhueTimeoutException and PhueRegistrationException:
def bridge_factory(ip): bridge = None # handle import try: from phue import Bridge, PhueRegistrationException, PhueTimeoutException except ImportError: exit(wording.get('package_no').format('PHUE') + wording.get('exclamation_mark')) # create instance try: bridge = Bridge(ip) except (PhueConnectionException, PhueTimeoutException): exit(wording.get('connection_no').format('PHILIPS HUE') + wording.get('exclamation_mark')) except PhueRegistrationException: exit(wording.get('press_button').format('PAIRING', 'PHILIPS HUE BRIDGE') + wording.get('exclamation_mark')) return bridge
Hello,
passing various invalid strings to the constructor is causing different errors and exceptions:
ip = 1.1.1
~ OSError: [Errno 101] Network is unreachableip = 1.1.1.1
~ json.decoder.JSONDecodeError: Expecting valuePhueRequestTimeout
does not always catchsocket.timeout
for some reasonsocket.timeout
online 743, in connect
andline 652, in request
it would be nice to have the following exceptions to be thrown:
Bridge()
so throwPhueConnectionException
PhueTimeoutException
PhueRegistrationException
Hacky solution that is currently working properly accept random
socket.timeout
:Wanted solution that throws
PhueConnectionException
,PhueTimeoutException
andPhueRegistrationException
: