Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: catch exceptions due to failure to create XML from text
I don't know what causes this, but we got a few 5xx errors from the Heroku logs with this trace: ``` File "/app/readalongs/web_api.py", line 209, in assemble parsed = parse_xml( ^^^^^^^^^^ File "/app/readalongs/text/util.py", line 138, in parse_xml return etree.fromstring( ^^^^^^^^^^^^^^^^^ lxml.etree.XMLSyntaxError: PCDATA invalid Char value 3, line 8, column 26 ``` While it makes no sense we should fail to parse XML we just generated in this broader block: ``` parsed = parse_xml( create_ras_from_text( (request.input_text or "").splitlines(keepends=True), text_languages=request.text_languages, ) ) ``` let's just put a try/except in there since we saw it live on Heroku. Whatever the error in the input is, though I cannot reproduce it, should generate a 422 HTTP code.
- Loading branch information