diff --git a/pywb/warcserver/handlers.py b/pywb/warcserver/handlers.py index 67b74ea4..70a2ffc3 100644 --- a/pywb/warcserver/handlers.py +++ b/pywb/warcserver/handlers.py @@ -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 diff --git a/tests/test_cdx_server_app.py b/tests/test_cdx_server_app.py index b0c4ea3b..7ed80b5c 100644 --- a/tests/test_cdx_server_app.py +++ b/tests/test_cdx_server_app.py @@ -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'}