catch errors in cli

This commit is contained in:
Jack Robison 2018-10-10 12:51:56 -04:00
parent a803bb57b3
commit f2ddc3166e
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -233,9 +233,13 @@ class UPnP:
lan_address, gateway_address, timeout, service, man, interface_name lan_address, gateway_address, timeout, service, man, interface_name
) )
else: else:
try:
u = await cls.discover( u = await cls.discover(
lan_address, gateway_address, timeout, service, man, interface_name lan_address, gateway_address, timeout, service, man, interface_name
) )
except UPnPError as err:
fut.set_exception(err)
return
if hasattr(u, method) and hasattr(getattr(u, method), "_cli"): if hasattr(u, method) and hasattr(getattr(u, method), "_cli"):
fn = getattr(u, method) fn = getattr(u, method)
else: else:
@ -254,7 +258,7 @@ class UPnP:
try: try:
result = fut.result() result = fut.result()
except UPnPError as err: except UPnPError as err:
print("error: %s" % str(err)) print("aioupnp encountered an error:\n%s" % str(err))
return return
if isinstance(result, (list, tuple, dict)): if isinstance(result, (list, tuple, dict)):