Raise runtime error if mercury API responds with empty response
This commit is contained in:
parent
8553a8eeb5
commit
3dd47260d6
1 changed files with 3 additions and 0 deletions
|
@ -61,6 +61,9 @@ class HttpWebpagePlugin(Plugin):
|
||||||
if not response or not response.ok:
|
if not response or not response.ok:
|
||||||
raise RuntimeError("Unable to parse content for {}: {}".format(url, response.reason))
|
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()))
|
self.logger.info('Got response from Mercury API: {}'.format(response.json()))
|
||||||
title = response.json().get('title', 'No_title_{}'.format(int(time.time())))
|
title = response.json().get('title', 'No_title_{}'.format(int(time.time())))
|
||||||
content = '<body style="{body_style}"><h1>{title}</h1>{content}</body>'.\
|
content = '<body style="{body_style}"><h1>{title}</h1>{content}</body>'.\
|
||||||
|
|
Loading…
Reference in a new issue