Strict exceptions compat

This commit is contained in:
Tanguy 2022-09-15 14:23:53 +02:00
parent 7fc1645e93
commit 082029cf25
No known key found for this signature in database
GPG Key ID: 7DD8EC6B6CE6C45E
1 changed files with 19 additions and 8 deletions

View File

@ -138,15 +138,22 @@ proc soapRequest(gateway: TUpnpGateway, actionName: string, args = initTable[str
let request = generateSoapEnveloppe(actionName, gateway.serviceType, args)
result = await postSoap(gateway.controlUri, request, gateway.serviceType & "#" & actionName)
try:
result.xmlTree = parseXml(result.body)["s:Body"]
if not isNil(result.xmlTree):
result.xmlTree = result.xmlTree[0]
result.xmlTree =
try:
parseXml(result.body)
except XmlError as exc:
trace "Cannot parse response XML", resp = result.body
return result
except Exception as exc:
#borken exception tracking on parseXml
doAssert false
nil
result.xmlTree = result.xmlTree["s:Body"]
if not isNil(result.xmlTree):
result.xmlTree = result.xmlTree[0]
for child in result.xmlTree:
result.response[child.tag.toLower()] = child.getStr()
except XmlError as exc:
trace "Cannot parse response XML", resp = result.body
for child in result.xmlTree:
result.response[child.tag.toLower()] = child.getStr()
return result
# UPNP
@ -215,6 +222,10 @@ proc tryGatewayLocation(tupnp: TUpnpSession, location: Uri) {.async.} =
except XmlError as exc:
debug "Can't decode XML from location", err = exc.msg
return
except Exception as exc:
#borken exception tracking on parseXml
doAssert false
nil
for service in pageXml.getAllRecur("service"):