aioupnp/txupnp/fault.py
2018-08-02 09:38:00 -04:00

14 lines
380 B
Python

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