1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 00:03:28 +01:00

IndexHandler: report BadRequestException as error while loading index (#625)

This commit is contained in:
Sebastian Nagel 2021-04-27 21:47:13 +02:00 committed by GitHub
parent 5d34018b9f
commit 106a9e9200
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -92,7 +92,11 @@ class IndexHandler(object):
errs = dict(last_exc=BadRequestException('output={0} not supported'.format(output)))
return None, None, errs
cdx_iter, errs = self._load_index_source(params)
cdx_iter = None
try:
cdx_iter, errs = self._load_index_source(params)
except BadRequestException as e:
errs = dict(last_exc=e)
if not cdx_iter:
return None, None, errs

View File

@ -296,4 +296,12 @@ class TestCDXApp(BaseTestClass):
assert resp.status_code == 400
assert resp.json == {'message': 'output=foo not supported'}
def test_error_unknown_match_type(self):
"""test unknown/unsupported matchType"""
resp = self.query('http://www.iana.org/_css/2013.1/print.css',
is_error=True,
fields='urlkey,timestamp,status',
matchType='foo')
assert resp.status_code == 400
assert resp.json == {'message': 'Invalid match_type: foo'}