Raise runtime error if mercury API responds with empty response

This commit is contained in:
Fabio Manganiello 2019-04-13 08:15:08 +00:00
parent 8553a8eeb5
commit 3dd47260d6
1 changed files with 3 additions and 0 deletions

View File

@ -61,6 +61,9 @@ class HttpWebpagePlugin(Plugin):
if not response or not response.ok:
raise RuntimeError("Unable to parse content for {}: {}".format(url, response.reason))
if not len(response.text):
raise RuntimeError("Empty response from Mercury API for URL {}".format(url))
self.logger.info('Got response from Mercury API: {}'.format(response.json()))
title = response.json().get('title', 'No_title_{}'.format(int(time.time())))
content = '<body style="{body_style}"><h1>{title}</h1>{content}</body>'.\