aioupnp/txupnp/fault.py

15 lines
380 B
Python
Raw Normal View History

2018-07-26 19:49:33 -04:00
from txupnp.util import flatten_keys
2018-07-28 22:08:24 -04:00
from txupnp.constants import FAULT, CONTROL
2018-07-26 19:49:33 -04:00
class UPnPError(Exception):
pass
def handle_fault(response):
if FAULT in response:
2018-07-28 22:08:24 -04:00
fault = flatten_keys(response[FAULT], "{%s}" % CONTROL)
2018-08-02 09:38:00 -04:00
error_description = fault['detail']['UPnPError']['errorDescription']
raise UPnPError(error_description)
2018-07-26 19:49:33 -04:00
return response