Skip to content

Commit

Permalink
Services API: Return reason for Send errors as part of raised exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoet committed Feb 17, 2020
1 parent ac33de4 commit 3131ddb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mythtv/bindings/python/MythTV/services_api/send.py
Expand Up @@ -6,6 +6,7 @@
from __future__ import absolute_import
from os import fdopen

from xml.etree import ElementTree
import re
import sys
import tempfile
Expand Down Expand Up @@ -249,8 +250,12 @@ def send(self, endpoint='', postdata=None, rest='', opts=None):
# TODO: Should handle redirects here (mostly for remote backends.)
if response.status_code > 299:
self.logger.debug('%s', response.text)
raise RuntimeError('Unexpected status returned: {}: URL was: {}'
.format(response.status_code, url))
reason = (ElementTree.fromstring(response.text)
.find('errorDescription').text)
raise RuntimeError('Unexpected status returned: {}: Reason: "{}" '
'URL was: {}'
.format(response.status_code,
reason, url))

self._validate_header(response.headers['Server'])

Expand Down

0 comments on commit 3131ddb

Please sign in to comment.