catch errors in cli
This commit is contained in:
parent
a803bb57b3
commit
f2ddc3166e
1 changed files with 8 additions and 4 deletions
|
@ -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)):
|
||||||
|
|
Loading…
Reference in a new issue