def _to_json(resp):
try:<EOL><INDENT>return resp.json()<EOL><DEDENT>except ValueError as e:<EOL><INDENT>six.raise_from(InvalidJSONError(<EOL>"<STR_LIT>" + resp.request.url<EOL>), e)<EOL><DEDENT>
Factors out some JSON parse code with error handling, to hopefully improve
error messages.

:param resp: A "requests" library response
:return: Parsed JSON.
:raises: InvalidJSONError If JSON parsing failed.