Skip to content

Commit

Permalink
Closes #164: Handle cases of NCBI error response without ERROR message
Browse files Browse the repository at this point in the history
  • Loading branch information
reece committed Dec 17, 2019
1 parent 0e6e2f0 commit 2e55029
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/eutils/_internal/queryservice.py
Expand Up @@ -311,7 +311,9 @@ def _cacheable(r):
raise EutilsRequestError('{r.reason} ({r.status_code}): {error}'.format(r=r, error=json["error"]))
try:
xml = lxml.etree.fromstring(r.text.encode('utf-8'))
raise EutilsRequestError('{r.reason} ({r.status_code}): {error}'.format(r=r, error=xml.find('ERROR').text))
errornode = xml.find('ERROR')
errormsg = errornode.text if errornode else "Unknown Error"
raise EutilsRequestError('{r.reason} ({r.status_code}): {error}'.format(r=r, error=errormsg))
except Exception as ex:
raise EutilsNCBIError('Error parsing response object from NCBI: {}'.format(ex))

Expand Down

0 comments on commit 2e55029

Please sign in to comment.