Skip to content

Commit

Permalink
add error return
Browse files Browse the repository at this point in the history
  • Loading branch information
cecicasco committed May 24, 2021
1 parent b8c6a00 commit e07ec38
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions kingfisher_scrapy/spiders/moldova.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ def parse_list(self, response):
base_url = 'http://public.eprocurement.systems/ocds/tenders/'
data = response.json()
# The last page returns an empty JSON object.
# Occasional error response with HTTP 200 code.
if not data or ('name' in data and data['name'] == 'Error'):
if not data:
return

# Occasional error response with HTTP 200 code.
if 'name' in data and data['name'] == 'Error':
return self.build_file_error_from_response(response, errors=data['stack'])

for item in data['data']:
url = replace_parameters(base_url, offset=None) + item['ocid']
yield self.build_request(url, formatter=components(-2))
Expand Down

0 comments on commit e07ec38

Please sign in to comment.