forked from platypush/platypush
Log exception and parser output if it returns invalid JSON
This commit is contained in:
parent
d64c519660
commit
beef06fad2
1 changed files with 6 additions and 1 deletions
|
@ -56,7 +56,12 @@ class HttpWebpagePlugin(Plugin):
|
||||||
|
|
||||||
self.logger.info('Parsing URL {}'.format(url))
|
self.logger.info('Parsing URL {}'.format(url))
|
||||||
parser = subprocess.Popen(['node', self._mercury_script, url], stdout=subprocess.PIPE)
|
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))
|
self.logger.info('Got response from Mercury API: {}'.format(response))
|
||||||
title = response.get('title', '{} on {}'.format(
|
title = response.get('title', '{} on {}'.format(
|
||||||
|
|
Loading…
Reference in a new issue