taxref: catch errors on JSON decoding

This commit is contained in:
dece 2022-09-12 12:37:32 +02:00
parent 65f9e8494a
commit 92f0ab3fef

View file

@ -73,7 +73,12 @@ class TaxrefPlugin(Plugin):
if response.status_code != 200: if response.status_code != 200:
self.signal_failure(target) self.signal_failure(target)
return return
data = response.json() try:
data = response.json()
except ValueError:
self.signal_failure(target)
return
items = data.get("_embedded", {}).get("taxa", []) items = data.get("_embedded", {}).get("taxa", [])
if not items: if not items:
@ -195,7 +200,11 @@ class TaxrefPlugin(Plugin):
if response.status_code != 200: if response.status_code != 200:
self.signal_failure(target) self.signal_failure(target)
return return
data = response.json() try:
data = response.json()
except ValueError:
self.signal_failure(target)
return
items = data.get("_embedded", {}).get("taxa", []) items = data.get("_embedded", {}).get("taxa", [])
if not items: if not items: