aioupnp/txupnp/fault.py

15 lines
394 B
Python
Raw Normal View History

2018-07-27 01:49:33 +02:00
from txupnp.util import flatten_keys
2018-07-29 04:08:24 +02:00
from txupnp.constants import FAULT, CONTROL
2018-07-27 01:49:33 +02:00
class UPnPError(Exception):
pass
2018-09-25 20:52:29 +02:00
def handle_fault(response: dict) -> dict:
2018-07-27 01:49:33 +02:00
if FAULT in response:
2018-07-29 04:08:24 +02:00
fault = flatten_keys(response[FAULT], "{%s}" % CONTROL)
2018-08-02 15:38:00 +02:00
error_description = fault['detail']['UPnPError']['errorDescription']
raise UPnPError(error_description)
2018-07-27 01:49:33 +02:00
return response