From 0e4c76275d96e541c1275494002872376255753b Mon Sep 17 00:00:00 2001 From: Hellowlol Date: Tue, 29 Sep 2015 09:16:28 +0200 Subject: [PATCH] If we fail to parse a response, log the uri. --- plexpy/http_handler.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/plexpy/http_handler.py b/plexpy/http_handler.py index 44a2b10b..d5a1d268 100644 --- a/plexpy/http_handler.py +++ b/plexpy/http_handler.py @@ -88,19 +88,24 @@ class HTTPHandler(object): return None if request_status == 200: - if output_format == 'dict': - output = helpers.convert_xml_to_dict(request_content) - elif output_format == 'json': - output = helpers.convert_xml_to_json(request_content) - elif output_format == 'xml': - output = helpers.parse_xml(request_content) - else: - output = request_content - - if return_type: - return output, content_type - - return output + try: + if output_format == 'dict': + output = helpers.convert_xml_to_dict(request_content) + elif output_format == 'json': + output = helpers.convert_xml_to_json(request_content) + elif output_format == 'xml': + output = helpers.parse_xml(request_content) + else: + output = request_content + + if return_type: + return output, content_type + + return output + + except Exception as e: + logger.warn(u"Failed to parse %s to %s %s" % (uri, output_type, e)) + return None else: logger.warn(u"Failed to access uri endpoint %s. Status code %r" % (uri, request_status)) return None