Skip to content

Uncaught exception in Querier object #90

@ehenneken

Description

@ehenneken

When Solr returns a non-200 response, an exception is raised to that effect. However, the code that initiates this query is unable to catch this exception. Therefore the service crashes with a traceback.

In the solrquery.py module:

            # all non-200 responses
            if response.status_code != 200:
                current_app.logger.error('Solr returned {response}.'.format(response=response))
                raise Solr("status_code %s"%response.status_code)

and in the solve.py module:

    solutions = query(query_string)

This is called in

        try:
            return solve_for_fields(hypothesis)
        except Undecidable as ex:
            possible_solutions.extend(ex.considered_solutions)
            reason = ex.reason
        except (NoSolution, OverflowOrNone) as ex:
            current_app.logger.debug("(%s)"%ex.__class__.__name__)
        except (Solr, KeyboardInterrupt):
            raise
        except Exception as ex:
            current_app.logger.error("Unhandled exception of type {0} occurred with arguments:{1!r}, thus killing a single hypothesis.".format(type(ex).__name__, ex.args))
            current_app.logger.error(traceback.format_exc())

The entire trace is below:

2025-11-24T21:35:11.298Z 298 ERROR    [3603124:Thread-1:app.py:1891] Exception on /xml [POST]
     Traceback (most recent call last):
       File "/proj/ads_abstracts/etc/edwin/projects/reference_service_dev/referencesrv/views.py", line 225, in xml_resolve
         resolved = str(solve_reference(Hypotheses(parsed_reference)))
       File "/proj/ads_abstracts/etc/edwin/projects/reference_service_dev/referencesrv/resolver/solve.py", line 341, in solve_reference
         return solve_for_fields(hypothesis)
       File "/proj/ads_abstracts/etc/edwin/projects/reference_service_dev/referencesrv/resolver/solve.py", line 281, in solve_for_fields
         solutions = query(query_string)
       File "/proj/ads_abstracts/etc/edwin/projects/reference_service_dev/referencesrv/resolver/solrquery.py", line 66, in query
         raise Solr("status_code %s"%response.status_code)
     referencesrv.resolver.common.Solr: status_code 401

     During handling of the above exception, another exception occurred:

     Traceback (most recent call last):
       File "/proj/ads_abstracts/etc/edwin/projects/reference_service_dev/venv_adsqb/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
         response = self.full_dispatch_request()
       File "/proj/ads_abstracts/etc/edwin/projects/reference_service_dev/venv_adsqb/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
         rv = self.handle_user_exception(e)
       File "/proj/ads_abstracts/etc/edwin/projects/reference_service_dev/venv_adsqb/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
         reraise(exc_type, exc_value, tb)
       File "/proj/ads_abstracts/etc/edwin/projects/reference_service_dev/venv_adsqb/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
         raise value
       File "/proj/ads_abstracts/etc/edwin/projects/reference_service_dev/venv_adsqb/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
         rv = self.dispatch_request()
       File "/proj/ads_abstracts/etc/edwin/projects/reference_service_dev/venv_adsqb/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
         return self.view_functions[rule.endpoint](**req.view_args)
       File "/proj/ads_abstracts/etc/edwin/projects/reference_service_dev/referencesrv/views.py", line 376, in xml_post
         results.append(xml_resolve(parsed_reference, returned_format))
       File "/proj/ads_abstracts/etc/edwin/projects/reference_service_dev/referencesrv/views.py", line 245, in xml_resolve
         resolved=str(solve_reference(Hypotheses(parsed_ref))),
       File "/proj/ads_abstracts/etc/edwin/projects/reference_service_dev/referencesrv/resolver/solve.py", line 341, in solve_reference
         return solve_for_fields(hypothesis)
       File "/proj/ads_abstracts/etc/edwin/projects/reference_service_dev/referencesrv/resolver/solve.py", line 281, in solve_for_fields
         solutions = query(query_string)
       File "/proj/ads_abstracts/etc/edwin/projects/reference_service_dev/referencesrv/resolver/solrquery.py", line 66, in query
         raise Solr("status_code %s"%response.status_code)
     referencesrv.resolver.common.Solr: status_code 401

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions