From beef06fad213f4b5c4855ba2777073ffae7d93e0 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 24 Jul 2019 23:31:27 +0000 Subject: [PATCH] Log exception and parser output if it returns invalid JSON --- platypush/plugins/http/webpage/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/platypush/plugins/http/webpage/__init__.py b/platypush/plugins/http/webpage/__init__.py index 0f230c0011..e92648f4f8 100644 --- a/platypush/plugins/http/webpage/__init__.py +++ b/platypush/plugins/http/webpage/__init__.py @@ -56,7 +56,12 @@ class HttpWebpagePlugin(Plugin): self.logger.info('Parsing URL {}'.format(url)) parser = subprocess.Popen(['node', self._mercury_script, url], stdout=subprocess.PIPE) - response = json.loads(parser.stdout.read().decode()) + response = parser.stdout.read().decode() + + try: + response = json.loads(response) + except Exception as e: + raise RuntimeError('Could not parse JSON: {}. Response: {}'.format(str(e), response)) self.logger.info('Got response from Mercury API: {}'.format(response)) title = response.get('title', '{} on {}'.format(