aioupnp/txupnp/fault.py
2018-09-25 14:52:29 -04:00

14 lines
394 B
Python

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