aioupnp/txupnp/fault.py
Jack Robison 418c8c632b
initial
2018-07-27 19:25:32 -04:00

13 lines
342 B
Python

from txupnp.util import flatten_keys
from txupnp.constants import FAULT, CONTROL_KEY
class UPnPError(Exception):
pass
def handle_fault(response):
if FAULT in response:
fault = flatten_keys(response[FAULT], "{%s}" % CONTROL_KEY)
raise UPnPError(fault['detail']['UPnPError']['errorDescription'])
return response